• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // This may look like C code, but it is really -*- C++ -*-
2 //
3 // Copyright Bob Friesenhahn, 1999, 2000, 2003
4 //
5 // Test STL averageImages function
6 //
7 
8 #include <Magick++.h>
9 #include <string>
10 #include <iostream>
11 #include <list>
12 #include <vector>
13 
14 using namespace std;
15 
16 using namespace Magick;
17 
main(int,char ** argv)18 int main( int /*argc*/, char ** argv)
19 {
20 
21   // Initialize ImageMagick install location for Windows
22   InitializeMagick(*argv);
23 
24   int failures=0;
25 
26   try {
27 
28     string srcdir("");
29     if(getenv("SRCDIR") != 0)
30       srcdir = getenv("SRCDIR");
31 
32     //
33     // Test averageImages
34     //
35 
36     list<Image> imageList;
37     readImages( &imageList, srcdir + "test_image_anim.miff" );
38 
39     Image averaged;
40     averageImages( &averaged, imageList.begin(), imageList.end() );
41     // averaged.display();
42     if (
43         ( averaged.signature() != "be10086221b349ccf2ca03bf4e18d68c75a4ab434814e16de8c9a347f3b7d68f") &&
44         ( averaged.signature() != "9706be2595aabde3ad70b70968e9a6a22de40c73da46c52b32539c05958f4813") &&
45         ( averaged.signature() != "90c4ba4b092f37a0600d51356f9aba89e7402ba3f59ac591ae216bace4a9d10b") &&
46         ( averaged.signature() != "2e9af094ccbb8c3c824980f597321aeef15d7accea84a5d233ba23e615d0c891") &&
47         ( averaged.signature() != "a88e978776d45b73bc8c9f37f6726cc9f14a3118b9a82384ee5acf488c5c2863") &&
48         ( averaged.signature() != "6bda37a8b6734ac271595f5b583d801cfb2479637401d056eae9be97127f558f") &&
49         ( averaged.signature() != "919a9e18a5e5ded83c2c4e5cfcd21d654802fcc14b06b02898d96fe28f04a1a1")
50        )
51       {
52 	cout << "Line: " << __LINE__
53 	     << "  Averaging image failed, signature = "
54 	     << averaged.signature() << endl;
55 	averaged.display();
56 	++failures;
57       }
58   }
59 
60   catch( Exception &error_ )
61     {
62       cout << "Caught exception: " << error_.what() << endl;
63       return 1;
64     }
65   catch( exception &error_ )
66     {
67       cout << "Caught exception: " << error_.what() << endl;
68       return 1;
69     }
70 
71   if ( failures )
72     {
73       cout << failures << " failures" << endl;
74       return 1;
75     }
76 
77   return 0;
78 }
79 
80