void showPerfCounters(LogLevel priority) { if (USE_PERFCOUNTERS) { if(rtArg.perfCounters) { LOG(priority, "Performance Counters\n--------------------------------\n"); LOG(priority, "%ld bytes allocated in heap\n", perfCounter.heapBytesAllocated); LOG(priority, "%ld bytes copied during GC\n", perfCounter.heapBytesCopied); LOG(priority, "%ld collections\n", perfCounter.heapCollections); LOG(priority, "%ld heap allocations\n", perfCounter.heapAllocations); showHistogram(priority, perfCounter.heapHistogram, "heap"); } if(rtArg.perfCounters > 1) { LOG(priority, "%ld bytes maximum heap size\n", perfCounter.heapMaxSize); } if(rtArg.perfCounters) { LOG(priority, "%ld bytes allocated in stack\n", perfCounter.stackBytesAllocated); LOG(priority, "%ld stack allocations\n", perfCounter.stackAllocations); showHistogram(priority, perfCounter.stackHistogram, "stack"); } if(rtArg.perfCounters > 1) { LOG(priority, "%ld bytes maximum stack size\n", perfCounter.stackMaxSize); } if(rtArg.perfCounters > 2) { LOG(priority, "total time %f sec\n", perfCounter.totalTime); LOG(priority, "GC time %f sec (%f%%)\n", perfCounter.gcTime, 100*perfCounter.gcTime/perfCounter.totalTime); } } }
void DkControlWidget::showWidgetsSettings() { if (mViewport->getImage().isNull()) { showPreview(false); showScroller(false); showMetaData(false); showFileInfo(false); showPlayer(false); showOverview(false); showHistogram(false); showCommentWidget(false); return; } //qDebug() << "current app mode: " << DkSettingsManager::param().app().currentAppMode; showOverview(mZoomWidget->getCurrentDisplaySetting()); showPreview(mFilePreview->getCurrentDisplaySetting()); showMetaData(mMetaDataInfo->getCurrentDisplaySetting()); showFileInfo(mFileInfoLabel->getCurrentDisplaySetting()); showPlayer(mPlayer->getCurrentDisplaySetting()); showHistogram(mHistogram->getCurrentDisplaySetting()); showCommentWidget(mCommentWidget->getCurrentDisplaySetting()); showScroller(mFolderScroll->getCurrentDisplaySetting()); }
int readData(OPTIONS options){ FASTQ oneSequence; int *histogram; if(options.showQualityHistogram=='T'){ histogram=(int *)calloc(QVALUEnUM, sizeof(int)); }else{ histogram=NULL; } while(!feof(stdin)){ oneSequence=readOneSequence(stdin); if(oneSequence.length==0){ break; } if(oneSequence.length!=0 && processSequence(options, &oneSequence)!=0){ if(histogram!=NULL){ histogram=cumulateHistogram(histogram, oneSequence); }else{ showResult(oneSequence); } }else{ /* fprintf(stderr, "skip\n"); */ } destroyFASTQ(&oneSequence); } if(histogram!=NULL){ showHistogram(histogram); free(histogram); } return 0; }
void DisplayWindow::changeImageLuminance() { Color c; double lum = ui->lineEditLum->text().toDouble(); img2 = c.changeImageBrightness(img2,lum); showImage(img2); if(ui->checkBoxHistogram->isChecked()==true) { showHistogram(); } }
void DisplayWindow::changeImageContrast() { Color c; double alpha = ui->lineEditAlpha->text().toDouble(); double beta = ui->lineEditBeta->text().toDouble(); img2 = c.changeImageContrast(origImg,alpha,beta); showImage(img2); if(ui->checkBoxHistogram->isChecked()==true) { showHistogram(); } }
void ppAnalyse(char *headersName, char *sizesName, char *pairsPsl, char *finDir, char *pairOut, char *mispairOut) /* ppAnalyse - Analyse paired plasmid reads. */ { struct hash *readHash = newHash(21); struct hash *pairHash = newHash(20); struct hash *fragHash = newHash(17); struct hash *finHash = NULL; struct hash *gsiHash = newHash(8); struct pairInfo *pairList = NULL, *measuredList, *pair; struct readInfo *readList = NULL, *rd; struct groupSizeInfo *gsiList = NULL, *gsi; int aliCount; int finCount; int i; struct slName *finList, *name; finHash = newHash(14); finList = listDir(finDir, "*.fa"); if ((finCount = slCount(finList)) == 0) errAbort("No fa files in %s\n", finDir); printf("Got %d (finished) .fa files in %s\n", finCount, finDir); for (name = finList; name != NULL; name = name->next) { chopSuffix(name->name); hashStore(finHash, name->name); } #ifdef SOMETIMES #endif /* SOMETIMES */ gsiList = readSizes(sizesName, gsiHash); printf("Got %d groups\n", slCount(gsiList)); readHeaders(headersName, readHash, pairHash, &readList, &pairList); slReverse(&readList); slReverse(&pairList); printf("Got %d reads in %d pairs\n", slCount(readList), slCount(pairList)); savePairs(pairOut, pairList, gsiHash); printf("Saved pairs to %s\n", pairOut); aliCount = readAlignments(pairsPsl, readHash, fragHash); printf("Got %d alignments in %s\n", aliCount, pairsPsl); doReadStats(readList, aliCount); doPairStats(pairList, finHash, gsiHash, mispairOut, &measuredList, &pairList); gsiMeanAndVariance(measuredList, gsiList, gsiHash, finHash); printf("Alignment length stats:\n"); for (i=0; i<10; ++i) { printf("%3d - %4d : %6d %4.2f%%\n", i*100, (i+1)*100, aliSizes[i], 100.0 * (double)aliSizes[i]/(double)aliCount); } doMeasuredStats(measuredList); for (gsi = gsiList; gsi != NULL; gsi = gsi->next) { if (gsi->measuredCount > 0) { printf("%s: mean %f, std %f, min %d, max %d, samples %d\n", gsi->name, gsi->measuredMean, sqrt(gsi->variance), gsi->measuredMin, gsi->measuredMax, gsi->measuredCount); printf(" %4.2f%% within guessed range (%d-%d)\n", 100.0 * (double)gsi->guessedCount/(double)gsi->measuredCount, gsi->guessedMin, gsi->guessedMax); printf(" w/in 200 %4.2f%%, w/in 400 %4.2f%%, w/in 800 %4.2f%%, w/in 1600 %4.3f%%, w/in 3200 %4.2f%%\n\n", gsiTight(gsi, 200), gsiTight(gsi, 400), gsiTight(gsi, 800), gsiTight(gsi, 1600), gsiTight(gsi, 3200) ); showHistogram(gsi); } } }
Visualizer& Visualizer::showHistogram(const char* name, const cv::Mat& img, float binsize, float min, float max) { std::string n(name); return showHistogram(n, img, binsize, min, max); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) { if (showInfoText()) { QString infoText; RimGeoMechCase* geoMechCase = geoMechView->geoMechCase(); RigGeoMechCaseData* caseData = geoMechCase ? geoMechCase->geoMechData() : NULL; RigFemPartCollection* femParts = caseData ? caseData->femParts() : NULL; if (femParts) { QString caseName = geoMechCase->caseUserDescription(); QString cellCount = QString("%1").arg(femParts->totalElementCount()); QString zScale = QString::number(geoMechView->scaleZ()); infoText = QString( "<p><b><center>-- %1 --</center></b><p>" "<b>Cell count:</b> %2 <b>Z-Scale:</b> %3<br>").arg(caseName, cellCount, zScale); if (geoMechView->hasUserRequestedAnimation() && geoMechView->cellResult()->hasResult()) { QString resultPos; QString fieldName = geoMechView->cellResult()->resultFieldUiName(); QString compName = geoMechView->cellResult()->resultComponentUiName(); if (!fieldName.isEmpty()) { switch (geoMechView->cellResult()->resultPositionType()) { case RIG_NODAL: resultPos = "Nodal"; break; case RIG_ELEMENT_NODAL: resultPos = "Element nodal"; break; case RIG_INTEGRATION_POINT: resultPos = "Integration point"; break; default: break; } infoText += QString( "<b>Cell result:</b> %1, %2, %3").arg(resultPos).arg(fieldName).arg(compName); double min = 0, max = 0; double p10 = 0, p90 = 0; double mean = 0; RigFemResultAddress resAddress = geoMechView->cellResult()->resultAddress(); caseData->femPartResults()->meanScalarValue(resAddress, &mean); caseData->femPartResults()->minMaxScalarValues(resAddress,&min, &max); // ToDo: Implement statistics for geomech data caseData->femPartResults()->p10p90ScalarValues(resAddress, &p10, &p90); infoText += QString("<table border=0 cellspacing=5 ><tr><td>Min</td><td>P10</td> <td>Mean</td> <td>P90</td> <td>Max</td> </tr>" "<tr><td>%1</td><td> %2</td><td> %3</td><td> %4</td><td> %5 </td></tr></table>").arg(min).arg(p10).arg(mean).arg(p90).arg(max); } else { infoText += QString("<br>"); } int currentTimeStep = geoMechView->currentTimeStep(); QString stepName = QString::fromStdString(caseData->femPartResults()->stepNames()[currentTimeStep]); infoText += QString("<b>Time Step:</b> %1 <b>Time:</b> %2").arg(currentTimeStep).arg(stepName); } } geoMechView->viewer()->setInfoText(infoText); } if (showHistogram()) { if (geoMechView->hasUserRequestedAnimation() && geoMechView->cellResult()->hasResult()) { geoMechView->viewer()->showHistogram(true); // ToDo: Implement statistics for geomech data RimGeoMechCase* geoMechCase = geoMechView->geoMechCase(); RigGeoMechCaseData* caseData = geoMechCase ? geoMechCase->geoMechData() : NULL; if (caseData) { double min = 0, max = 0; double p10 = 0, p90 = 0; double mean = 0; RigFemResultAddress resAddress = geoMechView->cellResult()->resultAddress(); caseData->femPartResults()->meanScalarValue(resAddress, &mean); caseData->femPartResults()->minMaxScalarValues(resAddress, &min, &max); caseData->femPartResults()->p10p90ScalarValues(resAddress, &p10, &p90); geoMechView->viewer()->setHistogram(min, max, caseData->femPartResults()->scalarValuesHistogram(resAddress)); geoMechView->viewer()->setHistogramPercentiles(p10, p90, mean); } } } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void Rim3dOverlayInfoConfig::updateReservoir3DInfo(RimEclipseView * reservoirView) { if (showInfoText()) { QString caseName; QString totCellCount; QString activeCellCountText; QString fractureActiveCellCount; QString iSize, jSize, kSize; QString zScale; QString propName; QString cellEdgeName; QString faultCellResultMapping; if (reservoirView->eclipseCase() && reservoirView->eclipseCase()->reservoirData() && reservoirView->eclipseCase()->reservoirData()->mainGrid()) { caseName = reservoirView->eclipseCase()->caseUserDescription(); totCellCount = QString::number(reservoirView->eclipseCase()->reservoirData()->mainGrid()->cells().size()); size_t mxActCellCount = reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->reservoirActiveCellCount(); size_t frActCellCount = reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->reservoirActiveCellCount(); if (frActCellCount > 0) activeCellCountText += "Matrix : "; activeCellCountText += QString::number(mxActCellCount); if (frActCellCount > 0) activeCellCountText += " Fracture : " + QString::number(frActCellCount); iSize = QString::number(reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountI()); jSize = QString::number(reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountJ()); kSize = QString::number(reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountK()); zScale = QString::number(reservoirView->scaleZ()); propName = reservoirView->cellResult()->resultVariable(); cellEdgeName = reservoirView->cellEdgeResult()->resultVariable(); } QString infoText = QString( "<p><b><center>-- %1 --</center></b><p> " "<b>Cell count. Total:</b> %2 <b>Active:</b> %3 <br>" "<b>Main Grid I,J,K:</b> %4, %5, %6 <b>Z-Scale:</b> %7<br>").arg(caseName, totCellCount, activeCellCountText, iSize, jSize, kSize, zScale); if (reservoirView->cellResult()->isTernarySaturationSelected()) { infoText += QString("<b>Cell Property:</b> %1 ").arg(propName); } if (reservoirView->hasUserRequestedAnimation() && reservoirView->cellResult()->hasResult()) { infoText += QString("<b>Cell Property:</b> %1 ").arg(propName); double min, max; double p10, p90; double mean; size_t scalarIndex = reservoirView->cellResult()->scalarResultIndex(); reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, min, max); reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, mean); //infoText += QString("<blockquote><b>Min:</b> %1 <b>P10:</b> %2 <b>Mean:</b> %3 <b>P90:</b> %4 <b>Max:</b> %5 </blockquote>").arg(min).arg(p10).arg(mean).arg(p90).arg(max); //infoText += QString("<blockquote><pre>Min: %1 P10: %2 Mean: %3 \n P90: %4 Max: %5 </pre></blockquote>").arg(min).arg(p10).arg(mean).arg(p90).arg(max); infoText += QString("<table border=0 cellspacing=5 ><tr><td>Min</td><td>P10</td> <td>Mean</td> <td>P90</td> <td>Max</td> </tr>" "<tr><td>%1</td><td> %2</td><td> %3</td><td> %4</td><td> %5 </td></tr></table>").arg(min).arg(p10).arg(mean).arg(p90).arg(max); if (reservoirView->faultResultSettings()->hasValidCustomResult()) { QString faultMapping; bool isShowingGrid = reservoirView->faultCollection()->isGridVisualizationMode(); if (!isShowingGrid) { if (reservoirView->faultCollection()->faultResult() == RimFaultCollection::FAULT_BACK_FACE_CULLING) { faultMapping = "Cells behind fault"; } else if (reservoirView->faultCollection()->faultResult() == RimFaultCollection::FAULT_FRONT_FACE_CULLING) { faultMapping = "Cells in front of fault"; } else { faultMapping = "Cells in front and behind fault"; } } else { faultMapping = "Cells in front and behind fault"; } infoText += QString("<b>Fault results: </b> %1<br>").arg(faultMapping); infoText += QString("<b>Fault Property:</b> %1 <br>").arg(reservoirView->faultResultSettings()->customFaultResult()->resultVariable()); } } else { infoText += "<br>"; } if (reservoirView->hasUserRequestedAnimation() && reservoirView->cellEdgeResult()->hasResult()) { double min, max; reservoirView->cellEdgeResult()->minMaxCellEdgeValues(min, max); infoText += QString("<b>Cell Edge Property:</b> %1 <blockquote>Min: %2 Max: %3 </blockquote>").arg(cellEdgeName).arg(min).arg(max); } if (reservoirView->cellResult()->hasDynamicResult() || reservoirView->propertyFilterCollection()->hasActiveDynamicFilters() || reservoirView->wellCollection()->hasVisibleWellPipes() || reservoirView->cellResult()->isTernarySaturationSelected()) { int currentTimeStep = reservoirView->currentTimeStep(); QDateTime date = reservoirView->currentGridCellResults()->cellResults()->timeStepDate(0, currentTimeStep); infoText += QString("<b>Time Step:</b> %1 <b>Time:</b> %2").arg(currentTimeStep).arg(date.toString("dd.MMM yyyy")); } reservoirView->viewer()->setInfoText(infoText); } if (showHistogram()) { if (reservoirView->hasUserRequestedAnimation() && reservoirView->cellResult()->hasResult()) { double min, max; double p10, p90; double mean; size_t scalarIndex = reservoirView->cellResult()->scalarResultIndex(); reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, min, max); reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, mean); reservoirView->viewer()->showHistogram(true); reservoirView->viewer()->setHistogram(min, max, reservoirView->currentGridCellResults()->cellResults()->cellScalarValuesHistogram(scalarIndex)); reservoirView->viewer()->setHistogramPercentiles(p10, p90, mean); } } }
void ImageViewer::contextMenuEvent(QContextMenuEvent *event) { if (!m_flipbook) return; QAction *action; if (m_isColorModel) { event->ignore(); return; } QMenu *menu = new QMenu(this); if (m_flipbook->getPreviewedFx()) { if (!(windowState() & Qt::WindowFullScreen)) { action = menu->addAction(tr("Clone Preview")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(MI_ClonePreview))); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(clonePreview())); } if (m_flipbook->isFreezed()) { action = menu->addAction(tr("Unfreeze Preview")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(MI_FreezePreview))); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(unfreezePreview())); } else { action = menu->addAction(tr("Freeze Preview")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(MI_FreezePreview))); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(freezePreview())); } action = menu->addAction(tr("Regenerate Preview")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(MI_RegeneratePreview))); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(regenerate())); action = menu->addAction(tr("Regenerate Frame Preview")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(MI_RegenerateFramePr))); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(regenerateFrame())); menu->addSeparator(); } action = menu->addAction(tr("Load / Append Images")); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(loadImages())); // history of the loaded paths of flipbook action = CommandManager::instance()->getAction(MI_LoadRecentImage); menu->addAction(action); action->setParent(m_flipbook); if (m_flipbook->isSavable()) { action = menu->addAction(tr("Save Images")); connect(action, SIGNAL(triggered()), m_flipbook, SLOT(saveImages())); } menu->addSeparator(); QAction *reset = menu->addAction(tr("Reset View")); reset->setShortcut( QKeySequence(CommandManager::instance()->getKeyFromId(V_ZoomReset))); connect(reset, SIGNAL(triggered()), SLOT(resetView())); QAction *fit = menu->addAction(tr("Fit To Window")); fit->setShortcut( QKeySequence(CommandManager::instance()->getKeyFromId(V_ZoomFit))); connect(fit, SIGNAL(triggered()), SLOT(fitView())); #ifdef _WIN32 if (ImageUtils::FullScreenWidget *fsWidget = dynamic_cast<ImageUtils::FullScreenWidget *>(parentWidget())) { bool isFullScreen = (fsWidget->windowState() & Qt::WindowFullScreen) != 0; action = menu->addAction(isFullScreen ? tr("Exit Full Screen Mode") : tr("Full Screen Mode")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(V_ShowHideFullScreen))); connect(action, SIGNAL(triggered()), fsWidget, SLOT(toggleFullScreen())); } #endif bool addedSep = false; if (m_isHistogramEnable && visibleRegion().contains(event->pos() * getDevPixRatio())) { menu->addSeparator(); addedSep = true; action = menu->addAction(tr("Show Histogram")); connect(action, SIGNAL(triggered()), SLOT(showHistogram())); } if (m_visualSettings.m_doCompare) { if (!addedSep) menu->addSeparator(); action = menu->addAction(tr("Swap Compared Images")); connect(action, SIGNAL(triggered()), SLOT(swapCompared())); } menu->exec(event->globalPos()); action = CommandManager::instance()->getAction(MI_LoadRecentImage); action->setParent(0); delete menu; update(); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) { RimGeoMechCase* geoMechCase = geoMechView->geoMechCase(); RigGeoMechCaseData* caseData = geoMechCase ? geoMechCase->geoMechData() : NULL; bool isResultsInfoRelevant = caseData && geoMechView->hasUserRequestedAnimation() && geoMechView->cellResultResultDefinition()->hasResult(); // Retreive result stats if needed double min = HUGE_VAL, max = HUGE_VAL; double p10 = HUGE_VAL, p90 = HUGE_VAL; double mean = HUGE_VAL; double sum = 0.0; const std::vector<size_t>* histogram = NULL; if (showResultInfo() || showHistogram()) { if (isResultsInfoRelevant) { RigFemResultAddress resAddress = geoMechView->cellResultResultDefinition()->resultAddress(); if (m_statisticsCellRange == ALL_CELLS) { if (m_statisticsTimeRange == ALL_TIMESTEPS) { caseData->femPartResults()->meanScalarValue(resAddress, &mean); caseData->femPartResults()->minMaxScalarValues(resAddress, &min, &max); caseData->femPartResults()->p10p90ScalarValues(resAddress, &p10, &p90); caseData->femPartResults()->sumScalarValue(resAddress, &sum); histogram = &(caseData->femPartResults()->scalarValuesHistogram(resAddress)); } else if (m_statisticsTimeRange == CURRENT_TIMESTEP) { int timeStepIdx = geoMechView->currentTimeStep(); caseData->femPartResults()->meanScalarValue(resAddress, timeStepIdx, &mean); caseData->femPartResults()->minMaxScalarValues(resAddress, timeStepIdx, &min, &max); caseData->femPartResults()->p10p90ScalarValues(resAddress, timeStepIdx, &p10, &p90); caseData->femPartResults()->sumScalarValue(resAddress, timeStepIdx, &sum); histogram = &(caseData->femPartResults()->scalarValuesHistogram(resAddress, timeStepIdx)); } } else if (m_statisticsCellRange == VISIBLE_CELLS) { this->updateVisCellStatsIfNeeded(); if (m_statisticsTimeRange == ALL_TIMESTEPS) { // TODO: Only valid if we have no dynamic property filter m_visibleCellStatistics->meanCellScalarValues(mean); m_visibleCellStatistics->minMaxCellScalarValues(min, max); m_visibleCellStatistics->p10p90CellScalarValues(p10, p90); m_visibleCellStatistics->sumCellScalarValues(sum); histogram = &(m_visibleCellStatistics->cellScalarValuesHistogram()); } else if (m_statisticsTimeRange == CURRENT_TIMESTEP) { int timeStepIdx = geoMechView->currentTimeStep(); m_visibleCellStatistics->meanCellScalarValues(timeStepIdx, mean); m_visibleCellStatistics->minMaxCellScalarValues(timeStepIdx, min, max); m_visibleCellStatistics->p10p90CellScalarValues(timeStepIdx, p10, p90); m_visibleCellStatistics->sumCellScalarValues(timeStepIdx, sum); histogram = &(m_visibleCellStatistics->cellScalarValuesHistogram(timeStepIdx)); } } } } // Compose text QString infoText; if (showCaseInfo()) { RigFemPartCollection* femParts = caseData ? caseData->femParts() : NULL; if (femParts) { QString caseName = geoMechCase->caseUserDescription(); QString cellCount = QString("%1").arg(femParts->totalElementCount()); QString zScale = QString::number(geoMechView->scaleZ()); infoText = QString( "<p><b><center>-- %1 --</center></b><p>" "<b>Cell count:</b> %2 <b>Z-Scale:</b> %3<br>").arg(caseName, cellCount, zScale); } } if (showResultInfo()) { if (isResultsInfoRelevant) { { QString resultPos; QString fieldName = geoMechView->cellResultResultDefinition()->resultFieldUiName(); QString compName = geoMechView->cellResultResultDefinition()->resultComponentUiName(); switch (geoMechView->cellResultResultDefinition()->resultPositionType()) { case RIG_NODAL: resultPos = "Nodal"; break; case RIG_ELEMENT_NODAL: resultPos = "Element nodal"; break; case RIG_INTEGRATION_POINT: resultPos = "Integration point"; break; default: break; } infoText += QString("<b>Cell result:</b> %1, %2, %3").arg(resultPos).arg(fieldName).arg(compName); } { infoText += QString("<br><b>Statistics:</b> ") + m_statisticsTimeRange().uiText() + " and " + m_statisticsCellRange().uiText(); infoText += QString("<table border=0 cellspacing=5 >" "<tr> <td>Min</td> <td>P10</td> <td>Mean</td> <td>P90</td> <td>Max</td> <td>Sum</td> </tr>" "<tr> <td>%1</td> <td> %2</td> <td> %3</td> <td> %4</td> <td> %5</td> <td> %6</td> </tr>" "</table>").arg(min).arg(p10).arg(mean).arg(p90).arg(max).arg(sum); } } } if (!infoText.isEmpty()) { geoMechView->viewer()->setInfoText(infoText); } // Populate histogram if (showHistogram()) { if (isResultsInfoRelevant) { geoMechView->viewer()->showHistogram(true); geoMechView->viewer()->setHistogram(min, max, *histogram); geoMechView->viewer()->setHistogramPercentiles(p10, p90, mean); } } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void Rim3dOverlayInfoConfig::updateEclipse3DInfo(RimEclipseView * eclipseView) { double min = HUGE_VAL, max = HUGE_VAL; double p10 = HUGE_VAL, p90 = HUGE_VAL; double mean = HUGE_VAL; double sum = 0.0; const std::vector<size_t>* histogram = NULL; bool isResultsInfoRelevant = eclipseView->hasUserRequestedAnimation() && eclipseView->cellResult()->hasResult(); if (showHistogram() || showResultInfo()) { if (isResultsInfoRelevant) { size_t scalarIndex = eclipseView->cellResult()->scalarResultIndex(); if (m_statisticsCellRange == ALL_CELLS) { if (m_statisticsTimeRange == ALL_TIMESTEPS) { eclipseView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, min, max); eclipseView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); eclipseView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, mean); eclipseView->currentGridCellResults()->cellResults()->sumCellScalarValues(scalarIndex, sum); histogram = &(eclipseView->currentGridCellResults()->cellResults()->cellScalarValuesHistogram(scalarIndex)); } else if (m_statisticsTimeRange == CURRENT_TIMESTEP ) { int timeStepIdx = eclipseView->currentTimeStep(); eclipseView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, timeStepIdx, min, max); eclipseView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, timeStepIdx, p10, p90); eclipseView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, timeStepIdx, mean); eclipseView->currentGridCellResults()->cellResults()->sumCellScalarValues(scalarIndex, timeStepIdx, sum); histogram = &(eclipseView->currentGridCellResults()->cellResults()->cellScalarValuesHistogram(scalarIndex, timeStepIdx)); } else { CVF_ASSERT(false); } } else if ( m_statisticsCellRange == VISIBLE_CELLS) { updateVisCellStatsIfNeeded(); if (m_statisticsTimeRange == ALL_TIMESTEPS) { // TODO: Only valid if we have no dynamic property filter m_visibleCellStatistics->meanCellScalarValues(mean); m_visibleCellStatistics->minMaxCellScalarValues(min, max); m_visibleCellStatistics->p10p90CellScalarValues(p10, p90); m_visibleCellStatistics->sumCellScalarValues(sum); histogram = &(m_visibleCellStatistics->cellScalarValuesHistogram()); } else if (m_statisticsTimeRange == CURRENT_TIMESTEP) { int currentTimeStep = eclipseView->currentTimeStep(); m_visibleCellStatistics->meanCellScalarValues(currentTimeStep, mean); m_visibleCellStatistics->minMaxCellScalarValues(currentTimeStep, min, max); m_visibleCellStatistics->p10p90CellScalarValues(currentTimeStep, p10, p90); m_visibleCellStatistics->sumCellScalarValues(currentTimeStep, sum); histogram = &(m_visibleCellStatistics->cellScalarValuesHistogram(currentTimeStep)); } } } } QString infoText; if (showCaseInfo()) { QString caseName; QString totCellCount; QString activeCellCountText; QString fractureActiveCellCount; QString iSize, jSize, kSize; QString zScale; if (eclipseView->eclipseCase() && eclipseView->eclipseCase()->reservoirData() && eclipseView->eclipseCase()->reservoirData()->mainGrid()) { caseName = eclipseView->eclipseCase()->caseUserDescription(); totCellCount = QString::number(eclipseView->eclipseCase()->reservoirData()->mainGrid()->globalCellArray().size()); size_t mxActCellCount = eclipseView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->reservoirActiveCellCount(); size_t frActCellCount = eclipseView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->reservoirActiveCellCount(); if (frActCellCount > 0) activeCellCountText += "Matrix : "; activeCellCountText += QString::number(mxActCellCount); if (frActCellCount > 0) activeCellCountText += " Fracture : " + QString::number(frActCellCount); iSize = QString::number(eclipseView->eclipseCase()->reservoirData()->mainGrid()->cellCountI()); jSize = QString::number(eclipseView->eclipseCase()->reservoirData()->mainGrid()->cellCountJ()); kSize = QString::number(eclipseView->eclipseCase()->reservoirData()->mainGrid()->cellCountK()); zScale = QString::number(eclipseView->scaleZ()); } infoText += QString( "<p><b><center>-- %1 --</center></b><p> " "<b>Cell count. Total:</b> %2 <b>Active:</b> %3 <br>" "<b>Main Grid I,J,K:</b> %4, %5, %6 <b>Z-Scale:</b> %7<br>").arg(caseName, totCellCount, activeCellCountText, iSize, jSize, kSize, zScale); } if (showResultInfo()) { if (eclipseView->cellResult()->isTernarySaturationSelected()) { QString propName = eclipseView->cellResult()->resultVariable(); infoText += QString("<b>Cell Property:</b> %1 ").arg(propName); } if (isResultsInfoRelevant) { QString propName = eclipseView->cellResult()->resultVariable(); infoText += QString("<b>Cell Property:</b> %1 ").arg(propName); infoText += QString("<br><b>Statistics:</b> ") + m_statisticsTimeRange().uiText() + " and " + m_statisticsCellRange().uiText(); infoText += QString("<table border=0 cellspacing=5 >" "<tr> <td>Min</td> <td>P10</td> <td>Mean</td> <td>P90</td> <td>Max</td> <td>Sum</td> </tr>" "<tr> <td>%1</td> <td> %2</td> <td> %3</td> <td> %4</td> <td> %5</td> <td> %6</td> </tr>" "</table>").arg(min).arg(p10).arg(mean).arg(p90).arg(max).arg(sum); if (eclipseView->faultResultSettings()->hasValidCustomResult()) { QString faultMapping; bool isShowingGrid = eclipseView->faultCollection()->isGridVisualizationMode(); if (!isShowingGrid) { if (eclipseView->faultCollection()->faultResult() == RimFaultCollection::FAULT_BACK_FACE_CULLING) { faultMapping = "Cells behind fault"; } else if (eclipseView->faultCollection()->faultResult() == RimFaultCollection::FAULT_FRONT_FACE_CULLING) { faultMapping = "Cells in front of fault"; } else { faultMapping = "Cells in front and behind fault"; } } else { faultMapping = "Cells in front and behind fault"; } infoText += QString("<b>Fault results: </b> %1<br>").arg(faultMapping); infoText += QString("<b>Fault Property:</b> %1 <br>").arg(eclipseView->faultResultSettings()->customFaultResult()->resultVariable()); } } if (eclipseView->hasUserRequestedAnimation() && eclipseView->cellEdgeResult()->hasResult()) { double min, max; QString cellEdgeName = eclipseView->cellEdgeResult()->resultVariable(); eclipseView->cellEdgeResult()->minMaxCellEdgeValues(min, max); infoText += QString("<b>Cell Edge Property:</b> %1 ").arg(cellEdgeName); infoText += QString("<table border=0 cellspacing=5 >" "<tr> <td>Min</td> <td></td> <td></td> <td></td> <td>Max</td> </tr>" "<tr> <td>%1</td> <td></td> <td></td> <td></td> <td> %2</td></tr>" "</table>").arg(min).arg(max); } } if (!infoText.isEmpty()) { eclipseView->viewer()->setInfoText(infoText); } if (showHistogram()) { if (isResultsInfoRelevant) { eclipseView->viewer()->showHistogram(true); eclipseView->viewer()->setHistogram(min, max, *histogram); eclipseView->viewer()->setHistogramPercentiles(p10, p90, mean); } } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void Rim3dOverlayInfoConfig::update3DInfo() { if (!m_reservoirView && m_reservoirView->viewer()) return; m_reservoirView->viewer()->showInfoText(showInfoText()); m_reservoirView->viewer()->showHistogram(false); m_reservoirView->viewer()->showAnimationProgress(showAnimProgress()); if (showInfoText()) { QString caseName; QString totCellCount; QString activeCellCount; QString iSize, jSize, kSize; QString propName; QString cellEdgeName; if (m_reservoirView->eclipseCase() && m_reservoirView->eclipseCase()->reservoirData()) { caseName = m_reservoirView->eclipseCase()->caseName(); totCellCount = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cells().size()); activeCellCount = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->numActiveCells()); iSize = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountI()); jSize = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountJ()); kSize = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountK()); propName = m_reservoirView->cellResult()->resultVariable(); cellEdgeName = m_reservoirView->cellEdgeResult()->resultVariable(); } QString infoText = QString( "<p><b><center>-- %1 --</center></b><p> " "<b>Cell count. Total:</b> %2 <b>Active:</b> %3 <br>" "<b>Main Grid I,J,K:</b> %4, %5, %6 <br>").arg(caseName, totCellCount, activeCellCount, iSize, jSize, kSize); if (m_reservoirView->animationMode() && m_reservoirView->cellResult()->hasResult()) { infoText += QString("<b>Cell Property:</b> %1 ").arg(propName); double min, max; double p10, p90; double mean; size_t scalarIndex = m_reservoirView->cellResult()->gridScalarIndex(); m_reservoirView->gridCellResults()->minMaxCellScalarValues(scalarIndex, min, max); m_reservoirView->gridCellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); m_reservoirView->gridCellResults()->meanCellScalarValues(scalarIndex, mean); //infoText += QString("<blockquote><b>Min:</b> %1 <b>P10:</b> %2 <b>Mean:</b> %3 <b>P90:</b> %4 <b>Max:</b> %5 </blockquote>").arg(min).arg(p10).arg(mean).arg(p90).arg(max); //infoText += QString("<blockquote><pre>Min: %1 P10: %2 Mean: %3 \n P90: %4 Max: %5 </pre></blockquote>").arg(min).arg(p10).arg(mean).arg(p90).arg(max); infoText += QString("<table border=0 cellspacing=5 ><tr><td>Min</td><td>P10</td> <td>Mean</td> <td>P90</td> <td>Max</td> </tr>" "<tr><td>%1</td><td> %2</td><td> %3</td><td> %4</td><td> %5 </td></tr></table>").arg(min).arg(p10).arg(mean).arg(p90).arg(max); } if (m_reservoirView->animationMode() && m_reservoirView->cellEdgeResult()->hasResult()) { double min, max; m_reservoirView->cellEdgeResult()->minMaxCellEdgeValues(min, max); infoText += QString("<b>Cell Edge Property:</b> %1 <blockquote>Min: %2 Max: %3 </blockquote>").arg(cellEdgeName).arg(min).arg(max); } if ( m_reservoirView->cellResult()->hasDynamicResult() || m_reservoirView->propertyFilterCollection()->hasActiveDynamicFilters() || m_reservoirView->wellCollection()->hasVisibleWellPipes()) { int currentTimeStep = m_reservoirView->currentTimeStep(); QDateTime date = m_reservoirView->gridCellResults()->timeStepDate(0, currentTimeStep); infoText += QString("<b>Time Step:</b> %1 <b>Time:</b> %2").arg(currentTimeStep).arg(date.toString("dd.MMM yyyy")); } m_reservoirView->viewer()->setInfoText(infoText); } if (showHistogram()) { if (m_reservoirView->animationMode() && m_reservoirView->cellResult()->hasResult()) { double min, max; double p10, p90; double mean; size_t scalarIndex = m_reservoirView->cellResult()->gridScalarIndex(); m_reservoirView->gridCellResults()->minMaxCellScalarValues(scalarIndex, min, max); m_reservoirView->gridCellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); m_reservoirView->gridCellResults()->meanCellScalarValues(scalarIndex, mean); m_reservoirView->viewer()->showHistogram(true); m_reservoirView->viewer()->setHistogram(min, max, m_reservoirView->gridCellResults()->cellScalarValuesHistogram(scalarIndex)); m_reservoirView->viewer()->setHistogramPercentiles(p10, p90, mean); } } }
bool PlayFieldDetectionModule::run() { if(firstTime) { if(imgARGB32.empty() || imgARGB32.data == NULL) { this->height = m_data->currentImage->height(); this->width = m_data->currentImage->width(); this->imgARGB32 = cv::Mat(height, width, CV_8UC4 ); } if(m_data->fgImage == NULL) { m_data->fgImage = new QImage(width,height, QImage::Format_Indexed8); m_data->fgImage->setColorTable(*(m_data->grayScaleTable)); memset(m_data->fgImage->bits(), 0, height*m_data->fgImage->bytesPerLine()); } if(m_data->reliabilityMap == NULL || m_data->reliabilityMap->isNull()) { m_data->reliabilityMap = new QImage(width,height, QImage::Format_ARGB32); } this->reliabilityNormalized = cv::Mat(height,width, CV_8UC1); this->nonField = cv::Mat(height, width, CV_8UC1 ); ptr_nonField = nonField.data; QByteArray string8bit = this->fileMaskName.toLocal8Bit(); #ifdef __OPENCV3__ this->fieldMask = cv::imread(string8bit.data(), cv::IMREAD_GRAYSCALE); #else this->fieldMask = cv::imread(string8bit.data(), CV_LOAD_IMAGE_GRAYSCALE ); #endif // if(fieldMask.empty() && !fileMaskName.compare("none")) if(fieldMask.empty() ) { // AppendToLog("PlayFieldDetectionModule: Warning: Mask Image "+ this->fileMaskName + " not found.\n"); this->useMask = false; } else { if(fieldMask.rows == height && fieldMask.cols == width) this->useMask = true; else { this->useMask = false; this->fieldMask = cv::Mat(); AppendToLog("PlayFieldDetectionModule: Warning: 'Mask Image' doesnt have the needed dimension. Mask Image won't be use.\n"); } } criteriaMap = cv::Mat(height, width, CV_8UC3, cv::Scalar(0,255,255));//yellow first criteria firstTime = false; } uchar *ptr_imgData = m_data->currentImage->bits(); memcpy(imgARGB32.data, ptr_imgData, m_data->currentImage->height()*m_data->currentImage->bytesPerLine()); #ifdef __OPENCV3__ cv::cvtColor(imgARGB32, currImgC3, cv::COLOR_RGBA2BGR); cv::cvtColor(currImgC3, currGrayImg, cv::COLOR_BGR2GRAY ); #else cv::cvtColor(imgARGB32, currImgC3, CV_RGBA2BGR); cv::cvtColor(currImgC3, currGrayImg, CV_BGR2GRAY ); #endif ptr_currGrayImg = currGrayImg.data; std::vector<cv::Mat> bgr_planes; cv::split( currImgC3, bgr_planes ); float range[] = { 0, 255} ; const float* histRange = { range }; cv::calcHist( &bgr_planes[0], 1, 0, this->fieldMask, blueHist, 1, &numBins, &histRange, true, false ); cv::calcHist( &bgr_planes[1], 1, 0, this->fieldMask, greenHist, 1, &numBins, &histRange, true, false ); cv::calcHist( &bgr_planes[2], 1, 0, this->fieldMask, redHist, 1, &numBins, &histRange, true, false ); cv::calcHist( &currGrayImg, 1, 0, this->fieldMask, grayHist, 1, &numBins, &histRange, true, false ); // percentilCut(blueHist, 1.5); // percentilCut(greenHist, 1.5); // percentilCut(redHist, 1.5); // percentilCut(grayHist, 1.5); if(this->displayHistogram) { showHistogram(blueHist, "blueHist"); showHistogram(greenHist, "greenHist"); showHistogram(redHist, "redHist"); showHistogram(grayHist, "grayHist"); } this->blueThreshold = calcThresh(blueHist,&this->bluePeak); this->greenThreshold = calcThresh(greenHist,&this->greenPeak); this->redThreshold = calcThresh(redHist,&this->redPeak); this->grayPeak = getMaxLoc( grayHist); float stdGray = 0, grayMean; grayMean = cv::mean(currGrayImg)[0]; for( int i = 0; i < currGrayImg.rows*currGrayImg.cols; i++) { stdGray += (ptr_currGrayImg[i] - grayMean ) * (ptr_currGrayImg[i] - grayMean ); } stdGray /= currGrayImg.rows*currGrayImg.cols; stdGray = sqrt(stdGray); // this->grayThreshold = this->grayPeak + this->beta * stdGray; this->grayThreshold = this->beta * stdGray; //hand sets values // this->bluePeak = 30; // this->greenPeak = 80; // this->redPeak = 0; // this->grayPeak = 74; // this->blueThreshold = 95; // this->greenThreshold = 200; // this->redThreshold = 90; // this->grayThreshold = grayPeak + this->beta * stdGray; // std::cout<<"blue: " <<(int)blueThreshold << " "<< (int)bluePeak <<std::endl; // std::cout<<"green "<< (int)greenThreshold << " "<< (int)greenPeak<<std::endl; // std::cout<<"red " <<(int)redThreshold << " "<< (int)redPeak<<std::endl; // std::cout<< "gray" <<(int)grayThreshold << " "<< (int)grayPeak<<std::endl; //grass clasification: 0 -> grass; 255-> non-grass ptr_blueChannel = bgr_planes[0].data, ptr_greenChannel = bgr_planes[1].data, ptr_redChannel = bgr_planes[2].data; ptr_nonField = nonField.data; memset(ptr_nonField, 255, nonField.cols * nonField.rows); //foreground classification featureMap = bgr_planes[2].clone(); for(int i = 0; i < width*height; i++) { if(this->useMask && fieldMask.data[i] == 0) { ptr_nonField[i] = 0; featureMap.data[i] = 0; continue; } minFeature = ptr_redChannel[i]; minReliability = normalizeBothSideScale(minFeature, ptr_greenChannel[i]); if( ptr_redChannel[i] < ptr_greenChannel[i] ) //criteria { reliability = normalizeBothSideScale(ptr_blueChannel[i], ptr_greenChannel[i]); if(minReliability > reliability) { minFeature = ptr_blueChannel[i]; minReliability = reliability; } //blue - green = cian criteriaMap.data[3*i] = 255; criteriaMap.data[3*i + 1] = 255; criteriaMap.data[3*i + 2] = 0; if( ptr_blueChannel[i] < ptr_greenChannel[i]) //criteria { threshold = greenPeak + greenThreshold; reliability = normalizeBothSideScale(ptr_greenChannel[i], threshold > 255? 255: threshold); if(minReliability > reliability) { minFeature = ptr_greenChannel[i]; minReliability = reliability; } //green criteriaMap.data[3*i] = 0; criteriaMap.data[3*i + 1] = 255; criteriaMap.data[3*i + 2] = 0; if( abs( ptr_greenChannel[i] - greenPeak ) <= greenThreshold) //criteria { threshold = bluePeak + blueThreshold; reliability = normalizeBothSideScale(ptr_blueChannel[i], threshold > 255? 255: threshold); if(minReliability > reliability) { minFeature = ptr_blueChannel[i]; minReliability = reliability; } //blue criteriaMap.data[3*i] = 255; criteriaMap.data[3*i + 1] = 0; criteriaMap.data[3*i + 2] = 0; if( abs( ptr_blueChannel[i] - bluePeak ) <= blueThreshold) //criteria { threshold = redPeak + redThreshold; reliability = normalizeBothSideScale(ptr_redChannel[i], threshold > 255? 255: threshold); if(minReliability > reliability) { minFeature = ptr_redChannel[i]; minReliability = reliability; } //red criteriaMap.data[3*i] = 0; criteriaMap.data[3*i + 1] = 0; criteriaMap.data[3*i + 2] = 255; if( abs( ptr_redChannel[i] - redPeak ) <= redThreshold) //criteria { threshold = grayPeak + grayThreshold; reliability = normalizeBothSideScale(ptr_currGrayImg[i], threshold > 255? 255: threshold); if(minReliability > reliability) { minFeature = ptr_currGrayImg[i]; minReliability = reliability; } //gray criteriaMap.data[3*i] = 127; criteriaMap.data[3*i + 1] = 127; criteriaMap.data[3*i + 2] = 127; if( abs(ptr_currGrayImg[i] - grayPeak) <= grayThreshold) //criteria { //gray criteriaMap.data[3*i] = 255; criteriaMap.data[3*i + 1] = 255; criteriaMap.data[3*i + 2] = 255; ptr_nonField[i] = 0; } } } } } } //linear scale this->featureMap.data[i] = this->minFeature; this->reliabilityNormalized.data[i] = this->minReliability; } //adaptative threshold, only for experimentation // cv::Mat binary; // cv::adaptiveThreshold(reliabilityNormalized, binary, 255, cv::ADAPTIVE_THRESH_MEAN_C, cv::THRESH_BINARY, 21, 13); // cv::threshold(reliabilityNormalized, binary, 125, 255, cv::THRESH_OTSU); // binary = binary == 0; // binary = binary & fieldMask; // cv::namedWindow("segmentation"); // cv::imshow("segmentation",binary); if(displayFeatureMap) { cv::Mat featureMapThermal = ThermalColor::reliabilityToThermal(featureMap); #ifdef __OPENCV3__ cv::cvtColor(featureMapThermal,featureMapThermal, cv::COLOR_BGR2RGB); #else cv::cvtColor(featureMapThermal,featureMapThermal, CV_BGR2RGB); #endif // cv::namedWindow("featureMap"); // cv::imshow("featureMap", featureMap); //grayscale cv::namedWindow("featureMapThermal"); cv::imshow("featureMapThermal", featureMapThermal); } if(displayCriteriaMap) { cv::namedWindow("Criteria"); cv::imshow("Criteria",criteriaMap); } //copy back foreground memcpy(m_data->fgImage->bits(), nonField.data, height*m_data->fgImage->bytesPerLine()); //copy back reliability // cv::namedWindow("reliability"); // cv::imshow("reliability",reliabilityNormalized); //grayScale reliabilityNormalizedThermal = ThermalColor::reliabilityToThermal(reliabilityNormalized); #ifdef __OPENCV3__ cv::cvtColor(reliabilityNormalizedThermal, imgARGB32, cv::COLOR_BGR2RGBA); #else cv::cvtColor(reliabilityNormalizedThermal, imgARGB32, CV_BGR2RGBA); #endif memcpy(m_data->reliabilityMap->bits(), imgARGB32.data, height * m_data->reliabilityMap->bytesPerLine()); return true; }