|
ThreeB 1.1
|
Code dealing with storm imagery (low level). More...
#include <gvars3/instances.h>#include <cvd/image_io.h>#include <cvd/convolution.h>#include <TooN/wls.h>#include <tr1/tuple>#include "storm_imagery.h"#include "debug.h"#include "utility.h"Go to the source code of this file.
Functions | |
| vector< Image< float > > | load_and_preprocess_images2 (const vector< string > &names) |
| vector< Image< float > > | load_and_preprocess_images (const vector< string > &names) |
| pair< double, double > | auto_fixed_scaling (const vector< Image< float > > &ims, double frac) |
| vector< Image< float > > | load_and_normalize_images (const vector< string > &files) |
Code dealing with storm imagery (low level).
Definition in file storm_imagery.cc.
| pair<double, double> auto_fixed_scaling | ( | const vector< Image< float > > & | ims, |
| double | frac | ||
| ) |
Compute the mean and variance of the (on average) darkest pixels, in order to find the correct scaling, by examining hte background.
Definition at line 197 of file storm_imagery.cc.
References assert_same_size(), and sq().
Referenced by load_and_normalize_images().
{
assert_same_size(ims);
//Compute the mean image (ish)
Image<double> ave(ims[0].size());
ave.fill(0);
for(unsigned int i=0; i < ims.size(); i++)
for(int y=0; y < ave.size().y; y++)
for(int x=0; x < ave.size().x; x++)
ave[y][x] += ims[i][y][x];
//Find the smallest N% of the pixels...
vector<pair<double, ImageRef> > pixels;
for(int y=0; y < ave.size().y; y++)
for(int x=0; x < ave.size().x; x++)
pixels.push_back(make_pair(ave[y][x], ImageRef(x,y)));
int npix = (int) floor(frac *pixels.size() + 0.5);
npix = max(0, min(npix, (int) pixels.size()));
nth_element(pixels.begin(), pixels.begin() + npix, pixels.end());
pixels.resize(npix);
//Now compute the mean and variance of those pixels.
double sum=0, sum2=0;
for(unsigned int i=0; i < ims.size(); i++)
{
for(unsigned int j=0; j < pixels.size(); j++)
{
sum += ims[i][pixels[j].second];
sum2 += sq(ims[i][pixels[j].second]);
}
}
double num = 1.0 * pixels.size() * ims.size();
double mean = sum / num;
double std = sqrt(((sum2/num) - mean*mean) * num / (num-1));
cout << "Automatic determination of fixed scaling:" << endl
<< "mean = " << mean << endl
<< "std = " << std << endl
<< "sqrt(mean) = " << sqrt(mean*255)/255 << endl;
return make_pair(mean, std);
}
1.7.4