27 template <
class TImageIn,
class TImageOut >
34 typedef typename TImageIn::value_type TPixelIn;
35 typedef typename TImageOut::value_type TPixelOut;
37 const TPixelIn EPSILON = 32 * std::numeric_limits<TPixelIn>::epsilon();
44 double maxIm = (double)
max(in);
45 double minIm = (double)
min(in);
46 if (
std::abs(maxIm - minIm) <= EPSILON)
58 double a = (t1max - t1min) / (maxIm - minIm);
59 double b = (t1min * maxIm - t1max*minIm) / (maxIm - minIm);
66 *iOut = castValue<TPixelIn,TPixelOut>(*iIn*a + b);
68 while (iIn.next() && iOut.next());
77 template <
class TImageIn,
class TImageOut >
84 typedef typename TImageIn::value_type TPixelIn;
85 typedef typename TImageOut::value_type TPixelOut;
99 throw std::overflow_error(
"Output type cannot handle input image range");
106 if (type_min<TPixelOut>() > type_min<TPixelIn>())
109 if (
min(in) < type_min<TPixelOut>())
113 throw std::overflow_error(
"Output type cannot handle input image range");
120 for (; !iIn.isAtEnd(); ++iIn, ++iOut)
122 *iOut = castValue<TPixelIn,TPixelOut>(*iIn);
A trait class to assign iterators to image types.
boost::enable_if< is_Image< TImage >, typename TImage::value_type >::type min(const TImage &im)
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.
numeric_array< T, D > abs(const numeric_array< T, D > &a)
Absolute value, element-wise.
TImage::value_type max(const TImage &im)
Returns the maximum intensity of the input image.
void convertScale(TImageIn const &in, TImageOut &out)
Convert an image into the type of the other image while scaling its intensity range to span through t...
void convert_im(TImageIn const &in, TImageOut &out)
Convert an image into the type of the other image.