\hypertarget{storm__imagery_8cc}{
\subsection{storm\_\-imagery.cc File Reference}
\label{storm__imagery_8cc}\index{storm\_\-imagery.cc@{storm\_\-imagery.cc}}
}


Code dealing with storm imagery (low level).  


{\ttfamily \#include $<$gvars3/instances.h$>$}\par
{\ttfamily \#include $<$cvd/image\_\-io.h$>$}\par
{\ttfamily \#include $<$cvd/convolution.h$>$}\par
{\ttfamily \#include $<$TooN/wls.h$>$}\par
{\ttfamily \#include $<$tr1/tuple$>$}\par
{\ttfamily \#include \char`\"{}storm\_\-imagery.h\char`\"{}}\par
{\ttfamily \#include \char`\"{}debug.h\char`\"{}}\par
{\ttfamily \#include \char`\"{}utility.h\char`\"{}}\par
\subsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
vector$<$ Image$<$ float $>$ $>$ \hyperlink{group__gStormImages_ga4509e1e3b18bde496a21bd5f7585fe6b}{load\_\-and\_\-preprocess\_\-images2} (const vector$<$ string $>$ \&names)
\item 
vector$<$ Image$<$ float $>$ $>$ \hyperlink{group__gStormImages_gac1d45d4c1c6cbc126ad5d73fb55a8fdf}{load\_\-and\_\-preprocess\_\-images} (const vector$<$ string $>$ \&names)
\item 
pair$<$ double, double $>$ \hyperlink{storm__imagery_8cc_a31e7070345c4f18f8c25cdf85121cfa4}{auto\_\-fixed\_\-scaling} (const vector$<$ Image$<$ float $>$ $>$ \&ims, double frac)
\item 
vector$<$ Image$<$ float $>$ $>$ \hyperlink{group__gStormImages_gaa2cd758c4ae34fc803f8bad9b80e5832}{load\_\-and\_\-normalize\_\-images} (const vector$<$ string $>$ \&files)
\end{DoxyCompactItemize}


\subsubsection{Detailed Description}
Code dealing with storm imagery (low level). 

Definition in file \hyperlink{storm__imagery_8cc_source}{storm\_\-imagery.cc}.



\subsubsection{Function Documentation}
\hypertarget{storm__imagery_8cc_a31e7070345c4f18f8c25cdf85121cfa4}{
\index{storm\_\-imagery.cc@{storm\_\-imagery.cc}!auto\_\-fixed\_\-scaling@{auto\_\-fixed\_\-scaling}}
\index{auto\_\-fixed\_\-scaling@{auto\_\-fixed\_\-scaling}!storm_imagery.cc@{storm\_\-imagery.cc}}
\paragraph[{auto\_\-fixed\_\-scaling}]{\setlength{\rightskip}{0pt plus 5cm}pair$<$double, double$>$ auto\_\-fixed\_\-scaling (
\begin{DoxyParamCaption}
\item[{const vector$<$ Image$<$ float $>$ $>$ \&}]{ims, }
\item[{double}]{frac}
\end{DoxyParamCaption}
)}}
\label{storm__imagery_8cc_a31e7070345c4f18f8c25cdf85121cfa4}


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 216 of file storm\_\-imagery.cc.



References assert\_\-same\_\-size(), and sq().



Referenced by load\_\-and\_\-normalize\_\-images().


\begin{DoxyCode}
{
    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);
}
\end{DoxyCode}
