29 #ifndef basisUtils_hpp
30 #define basisUtils_hpp
32 #include "../improc/eigenImage.hpp"
33 #include "../improc/eigenCube.hpp"
50 template<
typename realT>
55 for(
int i=0; i < modes.planes(); ++i)
57 modes.image(i) *= mask;
73 template<
typename realT>
79 realT maskSum = mask.sum();
80 for(
int i=0; i < modes.planes(); ++i)
82 float mean = (modes.image(i)*mask).sum()/maskSum;
84 modes.image(i) -= mean;
86 if(postMult) modes.image(i) *= mask;
102 template<
typename realT>
107 realT psum = mask.sum();
108 for(
int i=0; i < modes.planes(); ++i)
110 float norm = (modes.image(i)*mask).square().sum()/psum;
112 modes.image(i)/=sqrt(norm);
128 template<
typename realT>
133 bool subtract =
false,
138 if( N < 0) N = modes.planes();
141 realT apertureNPix = mask.sum();
147 else mean = (im*mask).sum()/apertureNPix;
152 for(
int i=0; i<N; ++i)
154 amps[i] = (im*modes.image(i)*mask).sum()/ apertureNPix;
158 im -= amps[i]*modes.image(i);
162 if(meanIgnore && !subtract)
Eigen::Array< scalarT, -1, -1 > eigenImage
Definition of the eigenImage type, which is an alias for Eigen::Array.
@ imageMedian
The median of each image (within the search region) is subtracted from itself.
int basisNormalize(improc::eigenCube< realT > &modes, improc::eigenImage< realT > &mask)
Normalize a basis set.
int basisMeanSub(improc::eigenCube< realT > &modes, improc::eigenImage< realT > &mask, bool postMult=true)
Mean-subtract a basis set.
int basisAmplitudes(std::vector< realT > &s, improc::eigenImage< realT > &im, improc::eigenCube< realT > &modes, improc::eigenImage< realT > &mask, bool subtract=false, int meanIgnore=0, int N=-1)
Measure the amplitudes of a set of basis modes fit to an image. Optionally subtract them.
int basisMask(improc::eigenCube< realT > &modes, improc::eigenImage< realT > &mask)
Mask a basis set.