48 OverlapStatistics::OverlapStatistics(
const PvlObject &inStats) {
68 QString progressMsg,
double sampPercent) {
73 if (sampPercent <= 0.0 || sampPercent > 100.0) {
74 string msg =
"The sampling percent must be a decimal (0.0, 100.0]";
78 p_sampPercent = sampPercent;
86 QString msg =
"Number of bands do not match between cubes [" +
87 p_xFile.name() +
"] and [" + p_yFile.name() +
"]";
91 p_stats.resize(p_bands);
98 if (*projX != *projY) {
99 QString msg =
"Mapping groups do not match between cubes [" +
100 p_xFile.name() +
"] and [" + p_yFile.name() +
"]";
116 if ((Xmin1 < Xmax2) && (Xmax1 > Xmin2) && (Ymin1 < Ymax2) && (Ymax1 > Ymin2)) {
117 double minX = Xmin1 > Xmin2 ? Xmin1 : Xmin2;
118 double minY = Ymin1 > Ymin2 ? Ymin1 : Ymin2;
119 double maxX = Xmax1 < Xmax2 ? Xmax1 : Xmax2;
120 double maxY = Ymax1 < Ymax2 ? Ymax1 : Ymax2;
123 p_minSampX = (int)(projX->
ToWorldX(minX) + 0.5);
124 p_maxSampX = (int)(projX->
ToWorldX(maxX) + 0.5);
125 p_minSampY = (int)(projY->
ToWorldX(minX) + 0.5);
126 p_maxSampY = (int)(projY->
ToWorldX(maxX) + 0.5);
127 p_sampRange = p_maxSampX - p_minSampX + 1;
130 if (p_sampRange <= 0)
return;
133 p_minLineX = (int)(projX->
ToWorldY(maxY) + 0.5);
134 p_maxLineX = (int)(projX->
ToWorldY(minY) + 0.5);
135 p_minLineY = (int)(projY->
ToWorldY(maxY) + 0.5);
136 p_maxLineY = (int)(projY->
ToWorldY(minY) + 0.5);
137 p_lineRange = p_maxLineX - p_minLineX + 1;
143 int linc = (int)(100.0 / sampPercent + 0.5);
148 int maxSteps = (int)(p_lineRange / linc + 0.5);
150 if (p_lineRange % linc != 0) maxSteps += 1;
158 for (
int band = 1; band <= p_bands; band++) {
163 while(i < p_lineRange) {
165 b2.SetBasePosition(p_minSampY, (i + p_minLineY), band);
168 p_stats[band-1].AddData(b1.DoubleBuffer(), b2.DoubleBuffer(), p_sampRange);
171 if (i + linc > p_lineRange - 1 && i != p_lineRange - 1) {
191 bool OverlapStatistics::HasOverlap()
const {
192 for (
int b = 0; b < p_bands; b++) {
193 if (p_stats[b].ValidPixels() > 0)
return true;
208 PvlObject OverlapStatistics::toPvl(QString name)
const {
211 if (name.isEmpty()) {
212 name =
"OverlapStatistics";
234 for (
int band = 1; band <= Bands(); band++) {
235 if (HasOverlap(band)) {
237 stdX +=
toString(GetMStats(band).X().StandardDeviation());
238 varX +=
toString(GetMStats(band).X().Variance());
258 for (
int band = 1; band <= Bands(); band++) {
259 if (HasOverlap(band)) {
261 stdY +=
toString(GetMStats(band).Y().StandardDeviation());
262 varY +=
toString(GetMStats(band).Y().Variance());
276 bool isValid =
false;
278 for (
int band = 1; band <= Bands(); band++) {
279 PvlKeyword validBand(
"ValidOverlap",
"false");
281 if (HasOverlap(band)) {
288 QString mStatsName =
"MultivariateStatistics" +
toString(band);
289 PvlObject mStats(GetMStats(band).toPvl(mStatsName));
293 PvlKeyword valid(
"Valid", (isValid) ?
"true" :
"false");
299 QString msg =
"Trivial overlap between [" + FileNameX().
name();
300 msg +=
"] and [" + FileNameY().name() +
"]";
311 void OverlapStatistics::fromPvl(
const PvlObject &inStats) {
316 p_xFile = inStats[
"File1"][0];
317 p_yFile = inStats[
"File2"][0];
318 p_sampRange = inStats[
"Width"];
319 p_lineRange = inStats[
"Height"];
320 p_bands = inStats[
"Bands"];
321 p_sampPercent = inStats[
"SamplingPercent"];
323 p_minSampX = fileX[
"StartSample"];
324 p_maxSampX = fileX[
"EndSample"];
325 p_minLineX = fileX[
"StartLine"];
326 p_maxLineX = fileX[
"EndLine"];
328 p_minSampY = fileY[
"StartSample"];
329 p_maxSampY = fileY[
"EndSample"];
330 p_minLineY = fileY[
"StartLine"];
331 p_maxLineY = fileY[
"EndLine"];
333 p_mincnt = inStats[
"MinCount"];
336 for (
int band = 1; band <= Bands(); band++) {
337 QString name =
"MultivariateStatistics" +
toString(band);
348 void OverlapStatistics::init() {
void SetMaximumSteps(const int steps)
This sets the maximum number of steps in the process.
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
PvlObject toPvl(QString name="OverlapStatistics") const
Creates a Pvl containing the following Overlap Statistics information File1 File2 Width Height Bands ...
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
void addGroup(const Isis::PvlGroup &group)
Add a group to the object.
Buffer for containing a three dimensional section of an image.
double ToProjectionX(const double worldX) const
This method converts a world x value to a projection x value.
Namespace for the standard library.
void SetBasePosition(const int start_sample, const int start_line, const int start_band)
This method is used to set the base position of the shape buffer.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Projection * projection()
void CheckStatus()
Checks and updates the status.
void addObject(const PvlObject &object)
Add a PvlObject.
QString name() const
Returns the container name.
std::ostream & operator<<(std::ostream &os, Isis::OverlapStatistics &stats)
Creates a pvl of various useful data obtained by the overlap statistics class.
double ToWorldX(const double projectionX) const
This method converts a projection x value to a world x value.
Base class for Map Projections.
Program progress reporter.
Container of multivariate statistics.
void AddSteps(const int steps)
If the initial step size was a guess, it can be modified using this method.
void SetText(const QString &text)
Changes the value of the text string reported just before 0% processed.
Contains multiple PvlContainers.
#define _FILEINFO_
Macro for the filename and line number.
double ToProjectionY(const double worldY) const
This method converts a world y value to a projection y value.
A single keyword-value pair.
void read(Blob &blob) const
This method will read data from the specified Blob object.
PixelType pixelType() const
Calculates statistics in the area of overlap between two projected cubes.
virtual QString fileName() const
Returns the opened cube's filename.
Namespace for ISIS/Bullet specific routines.
virtual int bandCount() const
Returns the number of virtual bands for the cube.
double ToWorldY(const double projectionY) const
This method converts a projection y value to a world y value.
void setValue(QString value, QString unit="")
Sets new values.
Contains Pvl Groups and Pvl Objects.
Functor for reduce using average functionality.
IO Handler for Isis Cubes.