1 #ifndef TIL_NORMALIZEDCORRELATION_H 2 #define TIL_NORMALIZEDCORRELATION_H 31 template <
class TImage1,
class TImage2>
145 template <
class TImage1,
class TImage2>
149 const t_corprec EPSILON = 4*std::numeric_limits<t_corprec>::epsilon() ;
156 if (m_stdIm1 <= EPSILON || m_stdIm2 <= EPSILON)
158 if (m_stdIm1 <= EPSILON && m_stdIm2 <= EPSILON)
165 throw std::runtime_error(
"Division by zero");
189 for (; !i1.isAtEnd(); ++i1, ++i2)
191 res +=
t_corprec(*i1 - m_meanIm1) * (*i2 - m_meanIm2);
196 return res / (m_im1.size() * m_stdIm1 * m_stdIm2);
A trait class to assign iterators to image types.
TImage2 & getSecondImage()
void setImages(TImage1 &im1, TImage2 &im2)
void sqrt(const TImage &in, TImage &out)
boost::enable_if< is_Image< TImage >, t_bsprec >::type var(const TImage &im, t_bsprec meanIm)
Returns the variance of the intensities of the input image (Normalization by size) ...
void similarityCheck(const TImage1 &im1, const TImage2 &im2)
Check whether both images are allocated and have the same size and voxel size.
Belongs to package Box Do not include directly, include til/Box.h instead.
General macros, definitions and functions.
TImage1 & getFirstImage()
INLINE void allocationCheck(const TImage &im)
Check whether smart pointer and image are allocated.
virtual ~NormalizedCorrelation()
void setSecondImage(TImage2 &im2)
t_bsprec mean(const TImage &im)
Returns the mean of the intensities of the input image.
void setFirstImage(TImage1 &im1)