www/api/Magick++/analyze_8cpp_source.html
| Magick++ 7.1.0 |
analyze.cpp
Go to the documentation of this file.
1 //
2 // Demonstrate using the 'analyze' process module to compute
3 // image statistics.
4 //
5 // Copyright Bob Friesenhahn, 2003, 2004
6 //
7 // Copyright @ 2013 ImageMagick Studio LLC, a non-profit organization
8 // dedicated to making software imaging solutions freely available.
9 //
10 // Usage: analyze file...
11 //
12
13 #include <Magick++.h>
14 #include <iostream>
15 #include <iomanip>
16 #include <list>
17 using namespace std;
18 using namespace Magick;
19 int main(int argc,char **argv)
20 {
21if ( argc < 2 )
22 {
23 cout << "Usage: " << argv[0] << " file..." << endl;
24 exit( 1 );
25 }
26
27// Initialize ImageMagick install location for Windows
28InitializeMagick(*argv);
29
30 {
31 std::list<std::string> attributes;
32
33 attributes.push_back("TopLeftColor");
34 attributes.push_back("TopRightColor");
35 attributes.push_back("BottomLeftColor");
36 attributes.push_back("BottomRightColor");
37 attributes.push_back("filter:brightness:mean");
38 attributes.push_back("filter:brightness:standard-deviation");
39 attributes.push_back("filter:brightness:kurtosis");
40 attributes.push_back("filter:brightness:skewness");
41 attributes.push_back("filter:saturation:mean");
42 attributes.push_back("filter:saturation:standard-deviation");
43 attributes.push_back("filter:saturation:kurtosis");
44 attributes.push_back("filter:saturation:skewness");
45
46char **arg = &argv[1];
47while ( *arg )
48 {
49string fname(*arg);
50try {
51 cout << "File: " << fname << endl;
52Image image( fname );
53
54/* Analyze module does not require an argument list */
55 image.process("analyze",0,0);
56
57 list<std::string>::iterator pos = attributes.begin();
58while(pos != attributes.end())
59 {
60 cout << " " << setw(16) << setfill(' ') << setiosflags(ios::left)
61 << *pos << " = " << image.attribute(*pos) << endl;
62 pos++;
63 }
64 }
65catch( Exception &error_ )
66 {
67 cout << error_.what() << endl;
68 }
69 ++arg;
70 }
71 }
72
73return 0;
74 }
virtual const char * what() const
Definition: Exception.cpp:58
void process(std::string name_, const ::ssize_t argc_, const char **argv_)
Definition: Image.cpp:3960
STL namespace.
int main(int argc, char **argv)
Definition: analyze.cpp:19
Definition: Exception.h:24
void attribute(const std::string name_, const char *value_)
Definition: Image.cpp:1985
Definition: Blob.h:17
MagickPPExport void InitializeMagick(const char *path_)
Definition: Functions.cpp:45
Definition: Image.h:55