#include "amma/PSImage.hh" #include "amma/RGBImage.hh" #include "amma/ByteImag.hh" #include "amma/Vector2d.hh" #include "amma/Matrix2d.hh" #include "amma/NumImage.hh" // This program generates 2 Postscript files of arbitrary "images" of vectors // and matrices respectively over an arbitrary background image int main() { // generate colour image RGBImageC im(200,100); FOREACH_PIXEL (im, p) { im[p].Red()=p.Row(); im[p].Green()=p.Col(); im[p].Blue()=190; } // generate image of vectors and print them over colour image NumImageC v(200,100); {FOREACH_PIXEL (v, p) {v[p] = Vector2dC(p.Row(), p.Col()/2.0);}} PSImageC pv ("vecs.ps", v.Rectangle(), 10, 5); pv.Title("Image of vectors"); pv.SetSizeMm (100); pv.Normalize(); pv.PrintImage(im); pv.SetPenColour(1,0,0); cerr << "Arrow normalisation factor = " << pv.PrintArrows (v) << '\n'; // generate image of 2x2 symmetric matrices and print them over grey image NumImageC m(ImageRectangleC(200,100)); FOREACH_PIXEL (m, p) { RealT sig_x = p.Row(); RealT sig_y = p.Col(); // RealT rho = 1.0 - (RealT)p.Row() / 100.0; RealT rho = 0.5; m[p] = Matrix2d2C(::Sqr(sig_x), rho * fabs(sig_x*sig_y), rho * fabs(sig_x*sig_y), ::Sqr(sig_y)); } PSImageC pm ("covs.ps", m.Rectangle(), 10, 0); pm.SetSizeMm (100); pm.Normalize(); pm.PrintImage(ByteImageC(im)); pm.SetPenColour(0,1,0); cerr << "Ellipse normalisation factor = " << pm.PrintEllipses (m) << '\n'; pm.SetPenColour(0,0,1); pm.DrawBorder(); }