Imagine++
Classes | Functions
Images Library

Classes

class  Imagine::Image< T, dim >
 Image. More...
 

Functions

template<typename T , int dim>
Image< T, dim > Imagine::blur (const Image< T, dim > &I, typename PixelTraits< T >::scalar_type sigma, bool neumann=true)
 Blur. More...
 
template<typename T , int dim>
Image< T, dim > Imagine::blur (const Image< T, dim > &I, const FVector< typename PixelTraits< T >::scalar_type, dim > &sigmas, bool neumann=true)
 Blur (anisotropic). More...
 
template<typename T , int dim>
Image< Color, dim > Imagine::color (const Image< RGB< T >, dim > &I, const RGB< T > &m, const RGB< T > &M)
 Color representation. More...
 
template<typename T , int dim>
Image< Color, dim > Imagine::color (const Image< RGB< T >, dim > &I)
 Color representation. More...
 
void Imagine::createMaskFromColor (Image< AlphaColor > &I, AlphaColor col)
 Create a transparency mask from a specified color-key. More...
 
template<typename T , int dim>
Image< T > Imagine::cut2D (const Image< T, dim > &I, const Coords< dim > &cut, int d1, int d2)
 2D cut. More...
 
template<typename T , int dim>
Image< T, dim > Imagine::deriche (const Image< T, dim > &I, typename PixelTraits< T >::scalar_type sigma, int order, int d, bool neumann=true)
 Deriche filter. More...
 
template<typename T , int dim>
Imagine::derivative (const Image< T, dim > &u, const Coords< dim > &p, int d)
 Derivative. More...
 
void Imagine::display (const Image< byte > &I, int x=0, int y=0, bool xorMode=false, double fact=1.)
 Display grey image. More...
 
void Imagine::display (const Image< byte > &I, IntPoint2 p, bool xorMode=false, double fact=1.)
 Display grey image (IntPoint2 alias).
 
void Imagine::display (const Image< Color > &I, int x=0, int y=0, bool xorMode=false, double fact=1.)
 Display color image. More...
 
void Imagine::display (const Image< AlphaColor > &I, int x=0, int y=0, bool xorMode=false, double fact=1.)
 Display color image with alpha channel. More...
 
void Imagine::display (const Image< Color > &I, IntPoint2 p, bool xorMode=false, double fact=1.)
 Display color image (IntPoint2 alias).
 
void Imagine::display (const Image< byte > &IR, const Image< byte > &IG, const Image< byte > &IB, int x=0, int y=0, bool xorMode=false, double fact=1.)
 Display color image (3 chanels). More...
 
void Imagine::display (const Image< byte > &IR, const Image< byte > &IG, const Image< byte > &IB, IntPoint2 p, bool xorMode=false, double fact=1.)
 Display color image (3 chanels, IntPoint2 alias).
 
template<typename T , int dim>
Image< T, dim > Imagine::enlarge (const Image< T, dim > &I, Coords< dim > nd, bool keepRatio=false)
 Enlarge image (given dimensions). More...
 
template<typename T >
Image< T, 2 > Imagine::enlarge (const Image< T, 2 > &I, int w, int h, bool keepRatio=false)
 Enlarge image (given dimensions), 2D alias.
 
template<typename T >
Image< T, 3 > Imagine::enlarge (const Image< T, 3 > &I, int w, int h, int d, bool keepRatio=false)
 Enlarge image (given dimensions), 3D alias.
 
template<typename T , int dim>
Image< T, dim > Imagine::enlarge (const Image< T, dim > &I, double fact)
 Enlarge image (given factor). More...
 
template<typename T >
Imagine::gaussianCurvature (const Image< T, 3 > &u, const Coords< 3 > &p)
 Gaussian curvature of iso level (3D). More...
 
template<typename T , int dim>
FVector< T, dim > Imagine::gradient (const Image< T, dim > &u, const Coords< dim > &p)
 Gradient. More...
 
template<typename T , int dim>
Image< byte, dim > Imagine::grey (const Image< T, dim > &I, T m, T M)
 Grey level representation. More...
 
template<typename T , int dim>
Image< byte, dim > Imagine::grey (const Image< T, dim > &I)
 Grey level representation. More...
 
template<typename T , int dim>
void Imagine::inPlaceBlur (Image< T, dim > &I, const FVector< typename PixelTraits< T >::scalar_type, dim > &sigmas, bool neumann=true)
 In Place Blur (anisotropic). More...
 
template<typename T , int dim>
void Imagine::inPlaceBlur (Image< T, dim > &I, typename PixelTraits< T >::scalar_type sigma, bool neumann=true)
 In Place Blur. More...
 
template<typename T , int dim>
void Imagine::inPlaceDeriche (Image< T, dim > &I, typename PixelTraits< T >::scalar_type sigma, int order, int d, bool neumann=true)
 In place Deriche filter. More...
 
template<typename T , int dim>
Imagine::laplacian (const Image< T, dim > &u, const Coords< dim > &p)
 Laplacian. More...
 
bool Imagine::load (Image< byte > &I, std::string name)
 Load grey image. More...
 
bool Imagine::load (Image< Color > &I, std::string name)
 Load color image. More...
 
bool Imagine::load (Image< AlphaColor > &I, std::string name)
 Load color image with alpha channel. More...
 
bool Imagine::load (Image< byte > &IR, Image< byte > &IG, Image< byte > &IB, std::string name)
 Load color image. More...
 
template<typename T , int dim>
bool Imagine::loadAnalyze (Image< T, dim > &I, const std::string name)
 Load Analyze file. More...
 
template<typename T >
Imagine::meanCurvature (const Image< T, 3 > &u, const Coords< 3 > &p)
 Mean curvature (3D). More...
 
template<typename T >
Imagine::meanCurvature (const Image< T, 2 > &u, const Coords< 2 > &p)
 Mean curvature (2D).
 
template<typename T >
Imagine::meanCurvatureMotion (const Image< T, 3 > &u, const Coords< 3 > &p)
 Level set Mean curvature motion (3D). More...
 
template<typename T >
Imagine::meanCurvatureMotion (const Image< T, 2 > &u, const Coords< 2 > &p)
 Level set Mean curvature motion (2D).
 
template<typename T , int dim>
void Imagine::neighbourCoords (const Image< T, dim > &u, const Coords< dim > &p, Coords< dim > &pp, Coords< dim > &pm)
 Coordinates of neighbours. More...
 
template<typename T , int dim>
void Imagine::neighbourOffsets (const Image< T, dim > &u, const Coords< dim > &p, FVector< size_t, dim > &dp, FVector< size_t, dim > &dm)
 Offsets to neighbours. More...
 
template<typename T , int dim>
FVector< T, dim > Imagine::normal (const Image< T, dim > &u, const Coords< dim > &p)
 Unit normal of iso level. More...
 
template<typename T , int dim>
Image< Color, dim > Imagine::rainbow (const Image< T, dim > &I, T m, T M)
 Rainbow representation. More...
 
template<typename T , int dim>
Image< Color, dim > Imagine::rainbow (const Image< T, dim > &I)
 Rainbow representation. More...
 
template<typename T , int dim>
Image< T, dim > Imagine::reduce (const Image< T, dim > &I, int fact)
 Reduce image (integer factor). More...
 
template<typename T , int dim>
Image< T, dim > Imagine::reduce (const Image< T, dim > &I, Coords< dim > nd, bool keepRatio=false)
 Reduce image (given dimensions). More...
 
template<typename T >
Image< T, 2 > Imagine::reduce (const Image< T, 2 > &I, int w, int h, bool keepRatio=false)
 Reduce image (given dimensions), 2D alias.
 
template<typename T >
Image< T, 3 > Imagine::reduce (const Image< T, 3 > &I, int w, int h, int d, bool keepRatio=false)
 Reduce image (given dimensions), 3D alias.
 
template<typename T , int dim>
Image< T, dim > Imagine::reduce (const Image< T, dim > &I, double fact)
 Reduce image (double factor). More...
 
bool Imagine::save (const Image< byte > &I, std::string name)
 Save grey image. More...
 
bool Imagine::save (const Image< Color > &I, std::string name, int quality=85)
 Save color image. More...
 
bool Imagine::save (Image< AlphaColor > &I, std::string name, int quality=85)
 Save color imagewith alpha channel. More...
 
bool Imagine::save (const Image< byte > &IR, const Image< byte > &IG, const Image< byte > &IB, std::string name, int quality=85)
 Save color image. More...
 
template<typename TO , typename TI , int dim>
bool Imagine::saveAnalyze (const Image< TI, dim > &I, const std::string name)
 Save Analyze file. More...
 
template<typename T , int dim>
Image< T, dim > Imagine::scaleDown (const Image< T, dim > &I, int fact)
 Down scaling: fast naive version. More...
 
template<typename T , int dim>
Image< T, dim > Imagine::scaleUp (const Image< T, dim > &I, int fact)
 Up scaling: fast naive version. More...
 

Detailed Description

Function Documentation

template<typename T , int dim>
Image<T,dim> Imagine::blur ( const Image< T, dim > &  I,
typename PixelTraits< T >::scalar_type  sigma,
bool  neumann = true 
)

Blur using Deriche

Parameters
Iinput image.
sigmasmoothing parameter
neumannNeumann border condition (default=true)
Returns
blurred image
display(color(blur(J,3)),0,3*h); // blur

Examples:
Images/test/test.cpp.
template<typename T , int dim>
Image<T,dim> Imagine::blur ( const Image< T, dim > &  I,
const FVector< typename PixelTraits< T >::scalar_type, dim > &  sigmas,
bool  neumann = true 
)

Anisotropic blur using Deriche

Parameters
Iinput image.
sigmassmoothing parameters (sigmas[i] in dimension i)
neumannNeumann border condition (default=true)
Returns
blurred image
inPlaceBlur(J,FVector<double,2>(3,.01)); // in place anisotropic blur

template<typename T , int dim>
Image<Color,dim> Imagine::color ( const Image< RGB< T >, dim > &  I,
const RGB< T > &  m,
const RGB< T > &  M 
)

Represents a RGB<T> image by a Color one (each coordinate being rescaled from 0 to 255 and stored to respective R,G or B channel)

Parameters
Iimage to represent
m,Mextremal values (For each channel, m[i] (or less) will be 0, M[i] (or more) 255)
display(color(L,RGB<double>(.2,.3,.1),RGB<double>(.8,1.,.6)),w,2*h); // to color (given range)

Examples:
Graphics/test/particles.cpp, and Images/test/test.cpp.
template<typename T , int dim>
Image<Color,dim> Imagine::color ( const Image< RGB< T >, dim > &  I)

Represents a RGB<T> image by a Color one (each coordinate being rescaled from 0 for min value to 255 for max value, and stored to respective R,G or B channel)

Parameters
Iimage to represent
display(color(L),0,2*h); // to color

void Imagine::createMaskFromColor ( Image< AlphaColor > &  I,
AlphaColor  col 
)
inline

Create a transparency mask from a specified color-key. Hides a color in current image by making it invisible.

Parameters
Iimage to modify
colcolor to hide
// Create mask
Image<AlphaColor> Ib;
load(Ib,srcPath("ryu.gif")); // Load Image
createMaskFromColor(Ib,Color(112,136,136)); // ...

Examples:
Images/test/test.cpp.
template<typename T , int dim>
Image<T> Imagine::cut2D ( const Image< T, dim > &  I,
const Coords< dim > &  cut,
int  d1,
int  d2 
)

Extract a 2D cut from a N-dimensional image

Parameters
Iimage to cut
cuta point of the cut (used to set every fixed coordinates).
d1the first moving coordinate.
d2the second moving coordinate.
display(cut2D(M,Coords<3>(0,5,0),0,2),2*w,2*h); // 2D cut (here {j=5})

Examples:
Images/test/test.cpp.
template<typename T , int dim>
Image<T,dim> Imagine::deriche ( const Image< T, dim > &  I,
typename PixelTraits< T >::scalar_type  sigma,
int  order,
int  d,
bool  neumann = true 
)

Deriche filter

Parameters
Iinput image.
sigmasmoothing parameter
orderorder of derivation (between 0 and 2)
ddimension of derivation
neumannNeumann border condition (default=true)
Returns
filtered image
Image< RGB<double> > J(I); // Deriche
display(color(deriche(J,3.,0,0)),w,2*h);
display(color(deriche(J,1.,1,1)),2*w,2*h); // ...

Examples:
Images/test/test.cpp.
template<typename T , int dim>
T Imagine::derivative ( const Image< T, dim > &  u,
const Coords< dim > &  p,
int  d 
)

PDE schemes. Derivative.

Parameters
uimage
pposition
ddirection
Returns
derivative
cout << derivative(u,p,0) << ' '; // Derivatives at p
cout << derivative(u,p,1) << ' ';
cout << derivative(u,p,2) << endl; // ...

Examples:
Images/test/test.cpp.
void Imagine::display ( const Image< byte > &  I,
int  x = 0,
int  y = 0,
bool  xorMode = false,
double  fact = 1. 
)
inline

Displays a grey image in current Window. NB: zooming factor is a fast hardware rendering and does not necesseraly use interpolation or anti aliasing.

Parameters
Iimage to display
x,yposition in window (default=(0,0))
xorModeXOR drawing (default=off). Used twice, recovers the original content
factscaling factor (default=1.)
display(I); // display grey

Examples:
Images/test/test.cpp.
void Imagine::display ( const Image< Color > &  I,
int  x = 0,
int  y = 0,
bool  xorMode = false,
double  fact = 1. 
)
inline

Displays a color image in current Window. NB: zooming factor is a fast hardware rendering and does not necesseraly use interpolation or anti aliasing.

Parameters
Iimage to display
x,yposition in window (default=(0,0))
xorModeXOR drawing (default=off). Used twice, recovers the original content
factscaling factor (default=1.)
display(J,w,0); // display color

void Imagine::display ( const Image< AlphaColor > &  I,
int  x = 0,
int  y = 0,
bool  xorMode = false,
double  fact = 1. 
)
inline

Displays a alpha color image in current Window. NB: zooming factor is a fast hardware rendering and does not necesseraly use interpolation or anti aliasing.

Parameters
Iimage to display
x,yposition in window (default=(0,0))
xorModeXOR drawing (default=off). Used twice, recovers the original content
factscaling factor (default=1.)
display(I); //Display PNG Image

void Imagine::display ( const Image< byte > &  IR,
const Image< byte > &  IG,
const Image< byte > &  IB,
int  x = 0,
int  y = 0,
bool  xorMode = false,
double  fact = 1. 
)
inline

Displays a color image given by 3 chanels in current Window. NB: zooming factor is a fast hardware rendering and does not necesseraly use interpolation or anti aliasing.

Parameters
IR,IG,IBimage to display
x,yposition in window (default=(0,0))
xorModeXOR drawing (default=off). Used twice, recovers the original content
factscaling factor (default=1.)
display(R,G,B,2*w,0,false,1.5); // display color (3 chanels)

template<typename T , int dim>
Image<T,dim> Imagine::enlarge ( const Image< T, dim > &  I,
Coords< dim >  nd,
bool  keepRatio = false 
)

Enlarges image to given dimensions. Interpolation is performed. If ratio is kept, extra parts of the reduced image are filled with the max value of the original one.

Parameters
Iimage to scale
ndenlarged dimensions.
keepRatiokeeps aspect ratio or not?
Returns
a larger image.
display(enlarge(I,400,400),350,h); // enlargement (dimensions)
display(enlarge(I,400,400,true),600,h); // ...

Examples:
Images/test/test.cpp.
template<typename T , int dim>
Image<T,dim> Imagine::enlarge ( const Image< T, dim > &  I,
double  fact 
)
inline

Enlarges image by a given factor. Interpolation is performed.

Parameters
Iimage to scale
factenlargement factor.
Returns
a larger image.
display(enlarge(I,1.5),0,2*h); // enlargement (factor)

template<typename T >
T Imagine::gaussianCurvature ( const Image< T, 3 > &  u,
const Coords< 3 > &  p 
)

PDE schemes. Gaussian curvature of iso level at p

Parameters
uimage
pposition
Returns
Gaussian curvature of iso level
cout << gaussianCurvature(u,p) << endl; // Gaussian curvature of iso level at p

Examples:
Images/test/test.cpp.
template<typename T , int dim>
FVector<T,dim> Imagine::gradient ( const Image< T, dim > &  u,
const Coords< dim > &  p 
)

PDE schemes. Gradient at p

Parameters
uimage
pposition
Returns
gradient
cout << gradient(u,p) << endl << normal(u,p) << endl; // Gradient and unit normal of iso level at p

Examples:
Images/test/test.cpp.
template<typename T , int dim>
Image<byte,dim> Imagine::grey ( const Image< T, dim > &  I,
m,
M 
)

Represents a scalar image by a grey scale (from BLACK to WHITE) for display purposes

Parameters
Iimage to represent
m,Mextremal values (m (or less) will be BLACK, M (or more) WHITE)
display(grey(K,.2,.8),3*w,h); // to grey (given range)

Examples:
Common/test/test.cpp, Graphics/test/example.cpp, Graphics/test/test.cpp, and Images/test/test.cpp.
template<typename T , int dim>
Image<byte,dim> Imagine::grey ( const Image< T, dim > &  I)

Represents a scalar image by a grey scale (from BLACK for min value to WHITE for max value) for display purposes

Parameters
Iimage to represent
display(grey(K),2*w,h); // to grey

template<typename T , int dim>
void Imagine::inPlaceBlur ( Image< T, dim > &  I,
const FVector< typename PixelTraits< T >::scalar_type, dim > &  sigmas,
bool  neumann = true 
)

In place anisotropic blur using Deriche

Parameters
Iinput/output image.
sigmassmoothing parameters (sigmas[i] for dimension i)
neumannNeumann border condition (default=true)
inPlaceBlur(J,FVector<double,2>(3,.01)); // in place anisotropic blur

Examples:
Images/test/test.cpp.
template<typename T , int dim>
void Imagine::inPlaceBlur ( Image< T, dim > &  I,
typename PixelTraits< T >::scalar_type  sigma,
bool  neumann = true 
)

In place blur using Deriche

Parameters
Iinput/output image.
sigmasmoothing parameter
neumannNeumann border condition (default=true)
inPlaceBlur(J,1.); // in place blur

template<typename T , int dim>
void Imagine::inPlaceDeriche ( Image< T, dim > &  I,
typename PixelTraits< T >::scalar_type  sigma,
int  order,
int  d,
bool  neumann = true 
)

In place Deriche filter

Parameters
Iinput/output image.
sigmasmoothing parameter
orderorder of derivation (between 0 and 2)
ddimension of derivation
neumannNeumann border condition (default=true)
inPlaceDeriche(J,2.,2,0); // in place Deriche
display(color(J),3*w,2*h); // ...

Examples:
Images/test/test.cpp.
template<typename T , int dim>
T Imagine::laplacian ( const Image< T, dim > &  u,
const Coords< dim > &  p 
)

PDE schemes. Laplacian.

Parameters
uimage
pposition
Returns
Laplacian
cout << laplacian(u,p) << endl; // Laplacian at p

Examples:
Images/test/test.cpp.
bool Imagine::load ( Image< byte > &  I,
std::string  name 
)
inline

Loads a grey (i.e byte) image from a file. Known formats are JPG, PNG, TIFF

Parameters
Iimage to load
namefile name
Returns
true if OK
load(I,srcPath("test.jpg")); // load grey

Examples:
Images/test/test.cpp.
bool Imagine::load ( Image< Color > &  I,
std::string  name 
)
inline

Loads a color (i.e Color) image from a file. Known formats are JPG, PNG, TIFF

Parameters
Iimage to load
namefile name
Returns
true if OK
load(J,srcPath("test.jpg")); // load color

bool Imagine::load ( Image< AlphaColor > &  I,
std::string  name 
)
inline

Loads a alpha color (i.e AlphaColor) image from a file. Known formats are JPG, PNG, TIFF, GIF. Prefer PNG for image with transparency displaying.

Parameters
Iimage to load
namefile name
Returns
true if OK
Image<AlphaColor> I; // Load PNG image
load(I, srcPath("sup.png"));
Image<AlphaColor> Ia;
load(Ia,srcPath("ryu.gif")); //Load GIF image
// Create mask
Image<AlphaColor> Ib;
load(Ib,srcPath("ryu.gif")); // Load Image
createMaskFromColor(Ib,Color(112,136,136)); // ...

bool Imagine::load ( Image< byte > &  IR,
Image< byte > &  IG,
Image< byte > &  IB,
std::string  name 
)
inline

Loads a color (i.e 3 chanels) images from a file. Known formats are JPG, PNG, TIFF

Parameters
IR,IG,IBR,G,B images to load
namefile name
Returns
true if OK
load(R,G,B,srcPath("test.jpg")); // load color chanels

template<typename T , int dim>
bool Imagine::loadAnalyze ( Image< T, dim > &  I,
const std::string  name 
)
inline

Loads an image from an Analyze file (medical imaging) (extensions IMG and HDR)

Parameters
Iimage to load
namefile name
Returns
true if OK
// Analyze tests
saveAnalyze<float>(I,"out"); // saving byte into float
Image<byte> I0,K0;
loadAnalyze(I0,"out"); // checking
if (I(10,10)!=I0(10,10))
cout << "Analyze error!!!" << endl;
saveAnalyze<double>(K,"out"); // saving double into double
loadAnalyze(K0,"out"); // checking
if (K(10,10)!=K0(10,10))
cout << "Analyze error!!!" << endl; // ...

Examples:
Images/test/test.cpp.
template<typename T >
T Imagine::meanCurvature ( const Image< T, 3 > &  u,
const Coords< 3 > &  p 
)

PDE schemes. Mean curvature of iso level at p.

Parameters
uimage
pposition
Returns
mean curvature
cout << meanCurvature(u,p) << endl; // Mean curvature of iso level at p

Examples:
Images/test/test.cpp.
template<typename T >
T Imagine::meanCurvatureMotion ( const Image< T, 3 > &  u,
const Coords< 3 > &  p 
)

PDE schemes. Level set Mean curvature motion at p

Parameters
uimage
pposition
Returns
mean curvature motion
cout << meanCurvatureMotion(u,p) << endl; // Level set Mean curvature motion at p

Examples:
Images/test/test.cpp.
template<typename T , int dim>
void Imagine::neighbourCoords ( const Image< T, dim > &  u,
const Coords< dim > &  p,
Coords< dim > &  pp,
Coords< dim > &  pm 
)

PDE schemes. Coordinates of neighbours of p in each direction. Set to p[i] when it would lead outside of the image.

Parameters
uimage
pposition
ppcoordinates of forward neighbours (change p[i] into pp[i] to get ith forward neighbour)
pmcoordinates of backward neighbours (change p[i] into pm[i] to get ith backward neighbour)
neighbourCoords(u,p0,pp,pm); // neighb coords

Examples:
Images/test/test.cpp.
template<typename T , int dim>
void Imagine::neighbourOffsets ( const Image< T, dim > &  u,
const Coords< dim > &  p,
FVector< size_t, dim > &  dp,
FVector< size_t, dim > &  dm 
)

PDE schemes. Offsets to neighbours of p in each direction. Set to 0 when it would lead outside of the image. Warning: dm is positive, thus -dm should be applied to get backward neighbour.

Parameters
uimage
pposition
dpoffsets to forward neighbors (dp[i] for ith dim)
dmoffsets to backward neighbors (dm[i] for ith dim)
neighbourOffsets(u,p0,dp,dm); // neighb offsets

Examples:
Images/test/test.cpp.
template<typename T , int dim>
FVector<T,dim> Imagine::normal ( const Image< T, dim > &  u,
const Coords< dim > &  p 
)

PDE schemes. Unit normal of iso level at p

Parameters
uimage
pposition
Returns
n normal
cout << gradient(u,p) << endl << normal(u,p) << endl; // Gradient and unit normal of iso level at p

Examples:
Images/test/test.cpp.
template<typename T , int dim>
Image<Color,dim> Imagine::rainbow ( const Image< T, dim > &  I,
m,
M 
)

Represents a scalar image by a rainbow scale (from RED to BLUE) for display purposes

Parameters
Iimage to represent
m,Mextremal values (m (or less) will be RED, M (or more) will be BLUE)
display(rainbow(K,.2,.8),w,h); // to rainbow (given range)

Examples:
Images/test/test.cpp.
template<typename T , int dim>
Image<Color,dim> Imagine::rainbow ( const Image< T, dim > &  I)

Represents a scalar image by a rainbow scale (from RED for min value to BLUE for max value) for display purposes

Parameters
Iimage to represent
display(rainbow(K),0,h); // to rainbow

template<typename T , int dim>
Image<T,dim> Imagine::reduce ( const Image< T, dim > &  I,
int  fact 
)

Reduces image by an integer factor. Each pixel is assigned with the mean of the corresponding original pixels.

Parameters
Iimage to scale
factdivider coefficient.
Returns
a smaller image.
display(reduce(I,2),7*w/2,0); // reduction (integer factor)

Examples:
Images/test/test.cpp.
template<typename T , int dim>
Image<T,dim> Imagine::reduce ( const Image< T, dim > &  I,
Coords< dim >  nd,
bool  keepRatio = false 
)

Reduces image to given dimensions. Anti aliasing is performed. If ratio is kept, extra parts of the reduced image are filled with the max value of the original one.

Parameters
Iimage to scale
ndreduced dimensions.
keepRatiokeeps aspect ratio or not?
Returns
a smaller image.
display(reduce(I,100,50),0,h); // reduction (dimensions)
display(reduce(I,100,50,true),100,h); // ...

template<typename T , int dim>
Image<T,dim> Imagine::reduce ( const Image< T, dim > &  I,
double  fact 
)
inline

Reduces image by a given fcator. Anti aliasing is performed.

Parameters
Iimage to scale
factreduction factor.
Returns
a smaller image.
display(reduce(I,1.6),200,h); // reduction (double factor)

bool Imagine::save ( const Image< byte > &  I,
std::string  name 
)
inline

Saves a grey (i.e byte) image to a file. Known formats are JPG, PNG, TIFF

Parameters
Iimage to save
namefile name
Returns
true if OK
save(I,"out_grey.png"); // save grey

Examples:
Images/test/test.cpp.
bool Imagine::save ( const Image< Color > &  I,
std::string  name,
int  quality = 85 
)
inline

Saves a color (i.e Color) image to a file. Known formats are JPG, PNG, TIFF

Parameters
Iimage to save
namefile name
qualityJpeg quality (between 0 and 100)
Returns
true if OK
save(J,"out_color.tif"); // save color
save(J,"out_color.jpg",95); // ...

bool Imagine::save ( Image< AlphaColor > &  I,
std::string  name,
int  quality = 85 
)
inline

Saves a alpha color (i.e AlphaColor) image to a file. Known formats are JPG, PNG, TIFF, GIF

Parameters
Iimage to save
namefile name
qualityJpeg quality (between 0 and 100)
Returns
true if OK
save(Ib,"out.png"); // save image with alpha channel

bool Imagine::save ( const Image< byte > &  IR,
const Image< byte > &  IG,
const Image< byte > &  IB,
std::string  name,
int  quality = 85 
)
inline

Saves a color (i.e 3 chanels) image to a file. Known formats are JPG, PNG, TIFF

Parameters
IR,IG,IBR,G,B chanels to save
namefile name
qualityJpeg quality (between 0 and 100)
Returns
true if OK
save(R,G,B,"out_color.png"); // save color chanels

template<typename TO , typename TI , int dim>
bool Imagine::saveAnalyze ( const Image< TI, dim > &  I,
const std::string  name 
)
inline

Saves an image into an Analyze file (medical imaging) (extensions IMG and HDR)

Template Parameters
T0output type
TIimage type
Parameters
Iimage to save
namefile name
Returns
true if OK
// Analyze tests
saveAnalyze<float>(I,"out"); // saving byte into float
Image<byte> I0,K0;
loadAnalyze(I0,"out"); // checking
if (I(10,10)!=I0(10,10))
cout << "Analyze error!!!" << endl;
saveAnalyze<double>(K,"out"); // saving double into double
loadAnalyze(K0,"out"); // checking
if (K(10,10)!=K0(10,10))
cout << "Analyze error!!!" << endl; // ...

Build header and data filenames and open files

template<typename T , int dim>
Image<T,dim> Imagine::scaleDown ( const Image< T, dim > &  I,
int  fact 
)

Scales image down. Fast naive version with no anti-aliasing: each pixel is assigneg with the value of one corresponding pixel in the original image.

Parameters
Iimage to scale
factdown scaling factor.
Returns
a smaller image.
display(scaleDown(I,2),3*w,0); // scale down (fast naive)

Examples:
Images/test/test.cpp.
template<typename T , int dim>
Image<T,dim> Imagine::scaleUp ( const Image< T, dim > &  I,
int  fact 
)

Scales image up. Fast naive version with no interpolation: each original pixel becomes a big constant one.

Parameters
Iimage to scale
factup scaling factor.
Returns
a larger image.
display(scaleUp(I,2),w,0); // scale up (fast naive)

Examples:
Images/test/test.cpp.