6 #include <geos/algorithm/ConvexHull.h> 7 #include <geos/geom/CoordinateSequence.h> 8 #include <geos/geom/CoordinateArraySequence.h> 9 #include <geos/geom/Envelope.h> 10 #include <geos/geom/Geometry.h> 11 #include <geos/geom/GeometryFactory.h> 12 #include <geos/geom/Polygon.h> 19 #include "CubeManager.h" 30 QString
sPointType [] = {
"Fixed",
"Constrained",
"Free" };
92 for (
int i=0; i<numSn; i++) {
109 pStatsGrp =
PvlGroup(
"ControlNetSummary");
213 geos::geom::GeometryFactory geosFactory;
226 foreach (QString sn, cnetSerials) {
227 geos::geom::CoordinateSequence * ptCoordinates =
228 new geos::geom::CoordinateArraySequence();
241 double cubeArea = imgStats[imgSamples] * imgStats[imgLines];
246 if (!measures.isEmpty()) {
249 imgStats[imgTotalPoints]++;
250 if (parentPoint->IsIgnored()) {
251 imgStats[imgIgnoredPoints]++;
254 imgStats[imgFixedPoints]++;
257 imgStats[imgConstrainedPoints]++;
260 imgStats[imgFreePoints]++;
262 if (parentPoint->IsEditLocked()) {
263 imgStats[imgLockedPoints]++;
266 imgStats[imgLocked]++;
268 ptCoordinates->add(geos::geom::Coordinate(measure->GetSample(),
269 measure->GetLine()));
272 ptCoordinates->add(geos::geom::Coordinate(measures[0]->GetSample(),
273 measures[0]->GetLine()));
276 if (ptCoordinates->size() >= 4) {
282 geos::geom::Geometry * convexHull = geosFactory.createPolygon(
283 geosFactory.createLinearRing(ptCoordinates), 0)->convexHull();
286 imgStats[imgConvexHullArea] = convexHull->getArea();
287 imgStats[imgConvexHullRatio] = imgStats[imgConvexHullArea] / cubeArea;
291 mConvexHullStats.
AddData(imgStats[imgConvexHullArea]);
296 delete ptCoordinates;
297 ptCoordinates = NULL;
318 QString msg =
"Serial Number of Images has not been provided to get Image Stats";
324 QString outName(outFile.
expanded());
325 ostm.open(outName.toLatin1().data(), std::ios::out);
328 QString msg = QObject::tr(
"Cannot open file [%1]").arg(psImageFile);
336 ostm <<
"Filename, SerialNumber, TotalPoints, PointsIgnored, PointsEditLocked, Fixed, Constrained, Free, ConvexHullRatio" << endl;
341 bool serialNumExists = it.value();
342 if (serialNumExists) {
344 ostm << imgStats[imgTotalPoints]<<
", " << imgStats[imgIgnoredPoints] <<
", " ;
345 ostm << imgStats[imgLockedPoints] <<
", " << imgStats[imgFixedPoints] <<
", " ;
346 ostm << imgStats[imgConstrainedPoints] <<
", " << imgStats[imgFreePoints] <<
", ";
347 ostm << imgStats[imgConvexHullRatio] << endl;
350 ostm <<
"0, 0, 0, 0, 0, 0, 0" << endl;
355 QString msg = QObject::tr(
"Error writing to file: [%1]").arg(psImageFile);
372 return (
mImageMap.find(psSerialNum)).value();
389 QString outName(outFile.
expanded());
390 ostm.open(outName.toLatin1().data(), std::ios::out);
393 QString msg = QObject::tr(
"Cannot open file [%1]").arg(psPointFile);
397 ostm <<
" PointId, PointType, PointIgnore, PointEditLock, TotalMeasures, MeasuresValid, MeasuresIgnore, MeasuresEditLock," << endl;
402 if (
mProgress != NULL && iNumPoints > 0) {
408 for (
int i = 0; i < iNumPoints; i++) {
410 int iNumMeasures = cPoint->GetNumMeasures();
412 int iIgnoredMeasures = iNumMeasures - iValidMeasures;
416 ostm <<
sBoolean[(int)cPoint->IsEditLocked()] <<
", " << iNumMeasures <<
", " << iValidMeasures <<
", ";
425 QString msg = QObject::tr(
"Error writing to file: [%1]").arg(psPointFile);
442 for (
int i=0; i<numPointIntStats; i++) {
451 for (
int i = 0; i < iNumPoints; i++) {
452 if (!
mCNet->GetPoint(i)->IsIgnored()) {
474 if (
mCNet->GetPoint(i)->IsEditLocked()) {
498 for (
int i = 0; i < numPointDblStats; i++) {
519 for (
int i = 0; i < iNumPoints; i++) {
522 if (!cp->IsIgnored()) {
523 for (
int cmIndex = 0; cmIndex < cp->GetNumMeasures(); cmIndex++) {
526 if (!cm->IsIgnored()) {
530 pixelShiftStats.
AddData(fabs(cm->GetPixelShift()));
537 UpdateMinMaxStats(resMagStats, minResidual, maxResidual);
540 &ControlMeasure::GetLineResidual);
541 UpdateMinMaxStats(resLineStats, minLineResidual, maxLineResidual);
544 &ControlMeasure::GetSampleResidual);
545 UpdateMinMaxStats(resSampStats, minSampleResidual, maxSampleResidual);
548 &ControlMeasure::GetPixelShift);
549 UpdateMinMaxStats(pixShiftStats, minPixelShift, maxPixelShift);
552 &ControlMeasure::GetLineShift);
553 UpdateMinMaxStats(lineShiftStats, minLineShift, maxLineShift);
556 &ControlMeasure::GetSampleShift);
557 UpdateMinMaxStats(sampShiftStats, minSampleShift, maxSampleShift);
561 UpdateMinMaxStats(gFitStats, minGFit, maxGFit);
567 dValue = fabs(minPixelZScoreStats.
Minimum());
576 dValue = fabs(maxPixelZScoreStats.
Maximum());
590 void ControlNetStatistics::UpdateMinMaxStats(
const Statistics & stats,
591 ePointDoubleStats min, ePointDoubleStats max) {
int NumValidPoints() const
Returns the Number of Valid (Not Ignored) Points in the Control Net.
QMap< QString, bool > mSerialNumMap
Whether serial# is part of ControlNet.
void GenerateImageStats()
Generate stats like Total, Ignored, Fixed Points in an Image.
const double Null
Value for an Isis Null pixel.
int NumMeasures() const
Returns the total Number of Measures in the Control Net.
void SetMaximumSteps(const int steps)
This sets the maximum number of steps in the process.
double GetMinLineShift() const
Get Min and Max LineShift.
int NumFreePoints() const
Returns the number of Constrained Points in Control Net.
void GeneratePointStats(const QString &psPointFile)
Generate stats like Ignored, Fixed, Total Measures, Ignored by Control Point.
A Constrained point is a Control Point whose lat/lon/radius is somewhat established and should not be...
A Fixed point is a Control Point whose lat/lon is well established and should not be changed...
File name manipulation and expansion.
double GetMinSampleResidual() const
Determine the minimum sample error of all points in the network.
double Minimum() const
Returns the absolute minimum double found in all data passed through the AddData method.
double GetMaxLineResidual() const
Determine the maximum line error of all points in the network.
QMap< int, int > mPointIntStats
Contains QMap of different count stats.
ControlNet * mCNet
Control Network.
const ControlMeasure * GetMeasure(QString serialNumber) const
Get a control measure based on its cube's serial number.
double GetMaxSampleResidual() const
Determine the maximum sample error of all points in the network.
QString serialNumber(const QString &filename)
Return a serial number given a filename.
double GetMaximumResidual() const
Determine the maximum error of all points in the network.
double GetResidualMagnitude() const
Return Residual magnitude.
double GetMinimumResidual() const
Determine the minimum error of all points in the network.
QString sPointType[]
String names for Point Type.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
BigInt ValidPixels() const
Returns the total number of valid pixels processed.
QVector< double > GetImageStatsBySerialNum(QString psSerialNum) const
Returns the Image Stats by Serial Number.
A type of error that occurred when performing an actual I/O operation.
int GetNumValidMeasures() const
void CheckStatus()
Checks and updates the status.
void GetPointDoubleStats()
Get Point stats for Residuals and Shifts.
Statistics GetStatistic(double(ControlMeasure::*statFunc)() const) const
This function will call a given method on every control measure that this point has.
A Free point is a Control Point that identifies common measurements between two or more cubes...
Control measures store z-scores in pairs.
void InitPointDoubleStats()
Init Pointstats std::vector.
QString fileName(const QString &sn)
Return a filename given a serial number.
void SetNumOpenCubes(unsigned int numCubes)
This sets the maximum number of opened cubes for this instance of CubeManager.
int NumValidMeasures() const
Returns the total Number of valid Measures in the Control Net.
double GetMaxPixelShift() const
Get network Max PixelShift.
double Maximum() const
Returns the absolute maximum double found in all data passed through the AddData method.
int GetNumPoints() const
Return the number of control points in the network.
This class is used to accumulate statistics on double arrays.
void GetPointIntStats()
Get point count stats.
void InitSerialNumMap()
Init SerialNum std::map.
Program progress reporter.
ControlNetStatistics(ControlNet *pCNet, const QString &psSerialNumFile, Progress *pProgress=0)
Constructor.
int GetNumLockedMeasures() const
Returns the number of locked control measures.
Statistics mConvexHullRatioStats
min, max, average convex hull stats
QString GetId() const
Return the Id of the control point.
void SetText(const QString &text)
Changes the value of the text string reported just before 0% processed.
~ControlNetStatistics()
Destructor.
Contains multiple PvlContainers.
int NumIgnoredMeasures() const
Returns the total Number of Ignored Measures in the Control Net.
#define _FILEINFO_
Macro for the filename and line number.
double GetAverageResidual() const
Determine the average error of all points in the network.
A type of error that could only have occurred due to a mistake on the user's part (e...
A single keyword-value pair.
QList< QString > GetCubeSerials() const
Use this method to get a complete list of all the cube serial numbers in the network.
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
double GetMinPixelShift() const
Get network Min PixelShift.
bool IsSpecial(const double d)
Returns if the input pixel is special.
SerialNumberList mSerialNumList
Serial Number List.
void PrintImageStats(const QString &psImageFile)
Print the Image Stats into specified output file.
int NumFixedPoints() const
Returns the Number of Fixed Points in the Control Net.
QString sBoolean[]
String values for Boolean.
Class for quick re-accessing of cubes based on file name.
int GetNumEditLockMeasures()
Return the total number of edit locked measures for all control points in the network.
int size() const
How many serial number / filename combos are in the list.
GoodnessOfFit is pointreg information for reference measures.
QMap< QString, QVector< double > > mImageMap
Contains stats by Image/Serial Num.
int NumConstrainedPoints() const
Returns the number of Constrained Points in Control Net.
double GetMaxSampleShift() const
Get network Max SampleShift.
int GetNumEditLockPoints()
Returns the number of edit locked control points.
double GetMinSampleShift() const
Get network Min SampleShift.
QList< ControlMeasure *> GetMeasuresInCube(QString serialNumber)
Get all the measures pertaining to a given cube serial number.
Progress * mProgress
Progress state.
double GetMaxLineShift() const
Get network Max LineShift.
Namespace for ISIS/Bullet specific routines.
bool IsEditLocked() const
Return value for p_editLock or implicit lock on reference measure.
double GetMinLineResidual() const
Determine the minimum line error of all points in the network.
PointType GetType() const
QMap< int, double > mPointDoubleStats
Contains QMap of different computed stats.
void AddData(const double *data, const unsigned int count)
Add an array of doubles to the accumulators and counters.
Serial Number list generator.
double GetAvgPixelShift() const
Get network Avg PixelShift.
double Average() const
Computes and returns the average.
Cube * OpenCube(const QString &cubeFileName)
This method opens a cube.
void GenerateControlNetStats(PvlGroup &pStatsGrp)
Generate the Control Net Stats into the PvlGroup.
IO Handler for Isis Cubes.