#include <Imagine/Images.h>
using namespace std;
void images() {
cout << "Testing Image functions!" << endl;
byte t1[]={1,2,3,4,5,6};
byte *t2=new byte[6];
for(
int i=0; i<Jb.
height(); i++)
for(
int j=0; j<Jb.
width(); j++)
Jb(j,i) = byte(rand()%256);
for(
int i=0; i<Jcb.
height(); i++)
for(
int j=0; j<Jcb.
width(); j++)
Jcb(j,i)=
Color(
byte(rand()%256),
byte(rand()%256),
byte(rand()%256));
A=E;
Jd=Jb;
Jcd=Jcb;
byte a,b,c,d;
a=b=c=d=a;
cout << sum(Jd) << ' ' << sum(Jcd) << endl;
cout << norm2(Jd) << ' ' << norm2(Jcd) << endl;
cout << norm(Jd) << ' ' << norm(Jcd) << endl;
O=-O;
O=O+P;
O+=P;
O=O-P;
O-=P;
O=P*2.;
O=2*P;
O*=2.;
O=P/2.;
O/=2.;
O=P*Q;
O*=Q;
O=P/Q;
O/=Q;
}
void io_transparency() {
cout << "Testing IO transparency functions!" << endl;
cout << "GIF opaque image" << endl;
cout << "Superimposed transparent PNG image" << endl;
cout << "Two transparent images" << endl;
cout << "Transparent image" << endl;
cout << "Saved and reloaded PNG transparent image" << endl;
}
void io() {
cout << "Testing IO functions!" << endl;
save(J,
"out_color.jpg",95);
save(R,G,B,
"out_color.png");
K/=255.;
L/=255.;
for (int k=0;k<110;k++)
for (int j=0;j<120;j++)
for (int i=0;i<130;i++)
M(i,j,k)=i+j+k;
saveAnalyze<float>(I,"out");
if (I(10,10)!=I0(10,10))
cout << "Analyze error!!!" << endl;
saveAnalyze<double>(K,"out");
if (K(10,10)!=K0(10,10))
cout << "Analyze error!!!" << endl;
}
void algos() {
cout << "Testing Algos functions!" << endl;
J=I;
}
void schemes(){
cout << "Testing PDE schemes" << endl;
cout << dp << " " << dm << endl;
cout << pp << " " << pm << endl;
}
int main() {
typedef void (*FUNC)();
vector< pair<string,FUNC> > tests;
#define ADD_TEST(func) \
tests.push_back(make_pair(string(#func), func));
ADD_TEST(images);
ADD_TEST(io);
ADD_TEST(algos);
ADD_TEST(schemes);
ADD_TEST(io_transparency);
std::vector< pair<string,FUNC> >::const_iterator it;
if(argc<=1)
for(it=tests.begin(); it!=tests.end(); ++it) {
cout << "---" << it->first << "---" << std::endl;
it->second();
}
else {
bool fail=false;
for(int i=1; i<argc; i++) {
for(it=tests.begin(); it!=tests.end(); ++it) {
if(it->first == argv[i]) {
cout << "---" << it->first << "---" << std::endl;
it->second();
break;
}
}
if(it==tests.end()) {
std::cout << "Unknown test " << argv[i] << endl;
fail = true;
}
}
if(fail) {
cout << "--- Available tests:" << endl;
for(it=tests.begin(); it!=tests.end(); ++it)
cout << it->first << ' ';
cout << endl;
return 0;
}
}
return 0;
}
Coordinates.
Definition: Coords.h:16
Iterator on Coordinates.
Definition: Coords.h:83
Vector of fixed size.
Definition: FVector.h:17
Image.
Definition: Image.h:24
Image getSubImage(const Coords< dim > &offset, const Coords< dim > &sz) const
Sub image.
Definition: Image.h:163
T mirror(const Coords< dim > &c) const
Mirror access.
Definition: Image.h:235
Image clone() const
Cloning.
Definition: Image.h:146
T invMirror(const Coords< dim > &c) const
Inversed mirror access.
Definition: Image.h:247
T neumann(const Coords< dim > &c) const
Neumann access.
Definition: Image.h:210
T dirichlet(const Coords< dim > &c, T out=T(0)) const
Dirichlet access.
Definition: Image.h:223
Image & fill(T x)
Filling.
Definition: Image.h:154
PixelTraits< T >::template CastPixel< V >::value_type interpolate(const FVector< V, dim > &c) const
Interpolation.
Definition: Image.h:198
int width() const
Size alias 0.
Definition: MultiArray.h:232
int height() const
Size alias 1.
Definition: MultiArray.h:239
RED GREEN BLUE color.
Definition: Color.h:26
#define srcPath(s)
Transform relative file path to absolute path.
Definition: Base.h:51
RGB< byte > Color
RGB<byte> alias.
Definition: Color.h:281
void closeWindow(Window w)
Close window.
Window openWindow(int w, int h, const std::string &windowTitle="Imagine++", int x=-1, int y=-1)
New window for 2D graphics.
void setActiveWindow(Window w, int subWin=0)
Set active window.
int click()
Wait for mouse click in active window.
WindowInternal * Window
Handle to a display window.
Definition: Types.h:48
void endGraphics()
Terminate graphics application.
int anyClick()
Wait for mouse click in any window.
void clearWindow()
clearWindow.
void neighbourCoords(const Image< T, dim > &u, const Coords< dim > &p, Coords< dim > &pp, Coords< dim > &pm)
Coordinates of neighbours.
Definition: Schemes.h:41
T meanCurvature(const Image< T, 3 > &u, const Coords< 3 > &p)
Mean curvature (3D).
Definition: Schemes.h:92
bool load(Image< byte > &I, std::string name)
Load grey image.
Definition: IO.h:37
Image< T, dim > enlarge(const Image< T, dim > &I, Coords< dim > nd, bool keepRatio=false)
Enlarge image (given dimensions).
Definition: Algos.h:137
Image< T, dim > scaleDown(const Image< T, dim > &I, int fact)
Down scaling: fast naive version.
Definition: Algos.h:45
T laplacian(const Image< T, dim > &u, const Coords< dim > &p)
Laplacian.
Definition: Schemes.h:74
T meanCurvatureMotion(const Image< T, 3 > &u, const Coords< 3 > &p)
Level set Mean curvature motion (3D).
Definition: Schemes.h:152
Image< byte, dim > grey(const Image< T, dim > &I, T m, T M)
Grey level representation.
Definition: IO.h:289
Image< T, dim > reduce(const Image< T, dim > &I, int fact)
Reduce image (integer factor).
Definition: Algos.h:62
FVector< T, dim > gradient(const Image< T, dim > &u, const Coords< dim > &p)
Gradient.
Definition: Schemes.h:350
Image< T, dim > scaleUp(const Image< T, dim > &I, int fact)
Up scaling: fast naive version.
Definition: Algos.h:23
Image< T > cut2D(const Image< T, dim > &I, const Coords< dim > &cut, int d1, int d2)
2D cut.
Definition: IO.h:218
Image< T, dim > blur(const Image< T, dim > &I, typename PixelTraits< T >::scalar_type sigma, bool neumann=true)
Blur.
Definition: Algos.h:352
void inPlaceBlur(Image< T, dim > &I, const FVector< typename PixelTraits< T >::scalar_type, dim > &sigmas, bool neumann=true)
In Place Blur (anisotropic).
Definition: Algos.h:325
FVector< T, dim > normal(const Image< T, dim > &u, const Coords< dim > &p)
Unit normal of iso level.
Definition: Schemes.h:334
bool loadAnalyze(Image< T, dim > &I, const std::string name)
Load Analyze file.
Definition: Analyze.h:36
void createMaskFromColor(Image< AlphaColor > &I, AlphaColor col)
Create a transparency mask from a specified color-key.
Definition: IO.h:22
T derivative(const Image< T, dim > &u, const Coords< dim > &p, int d)
Derivative.
Definition: Schemes.h:58
Image< Color, dim > color(const Image< RGB< T >, dim > &I, const RGB< T > &m, const RGB< T > &M)
Color representation.
Definition: IO.h:322
T gaussianCurvature(const Image< T, 3 > &u, const Coords< 3 > &p)
Gaussian curvature of iso level (3D).
Definition: Schemes.h:278
bool save(const Image< byte > &I, std::string name)
Save grey image.
Definition: IO.h:53
Image< T, dim > deriche(const Image< T, dim > &I, typename PixelTraits< T >::scalar_type sigma, int order, int d, bool neumann=true)
Deriche filter.
Definition: Algos.h:311
void neighbourOffsets(const Image< T, dim > &u, const Coords< dim > &p, FVector< size_t, dim > &dp, FVector< size_t, dim > &dm)
Offsets to neighbours.
Definition: Schemes.h:25
void display(const Image< byte > &I, int x=0, int y=0, bool xorMode=false, double fact=1.)
Display grey image.
Definition: IO.h:161
Image< Color, dim > rainbow(const Image< T, dim > &I, T m, T M)
Rainbow representation.
Definition: IO.h:259
void inPlaceDeriche(Image< T, dim > &I, typename PixelTraits< T >::scalar_type sigma, int order, int d, bool neumann=true)
In place Deriche filter.
Definition: Algos.h:188