Magick++
7.1.2-29
Convert, Edit, Or Compose Bitmap Images
Toggle main menu visibility
Loading...
Searching...
No Matches
analyze.cpp
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 <cstdlib>
15
#include <iostream>
16
#include <iomanip>
17
#include <list>
18
using namespace
std;
19
using namespace
Magick;
20
21
int
main(
int
argc,
char
**argv)
22
{
23
if
( argc < 2 )
24
{
25
cout <<
"Usage: "
<< argv[0] <<
" file..."
<< endl;
26
exit( 1 );
27
}
28
29
// Initialize ImageMagick install location for Windows
30
MagickPlusPlusGenesis
genesis(*argv);
31
32
{
33
std::list<std::string> attributes;
34
35
attributes.push_back(
"TopLeftColor"
);
36
attributes.push_back(
"TopRightColor"
);
37
attributes.push_back(
"BottomLeftColor"
);
38
attributes.push_back(
"BottomRightColor"
);
39
attributes.push_back(
"filter:brightness:mean"
);
40
attributes.push_back(
"filter:brightness:standard-deviation"
);
41
attributes.push_back(
"filter:brightness:kurtosis"
);
42
attributes.push_back(
"filter:brightness:skewness"
);
43
attributes.push_back(
"filter:saturation:mean"
);
44
attributes.push_back(
"filter:saturation:standard-deviation"
);
45
attributes.push_back(
"filter:saturation:kurtosis"
);
46
attributes.push_back(
"filter:saturation:skewness"
);
47
48
char
**arg = &argv[1];
49
while
( *arg )
50
{
51
string
fname(*arg);
52
try
{
53
cout <<
"File: "
<< fname << endl;
54
Image
image( fname );
55
56
/* Analyze module does not require an argument list */
57
image.process(
"analyze"
,0,0);
58
59
list<std::string>::iterator pos = attributes.begin();
60
while
(pos != attributes.end())
61
{
62
cout <<
" "
<< setw(16) << setfill(
' '
) << setiosflags(ios::left)
63
<< *pos <<
" = "
<< image.attribute(*pos) << endl;
64
pos++;
65
}
66
}
67
catch
(
Exception
&error_ )
68
{
69
cout << error_.what() << endl;
70
}
71
++arg;
72
}
73
}
74
75
return
0;
76
}
Magick::Exception
Definition
Exception.h:25
Magick::Image
Definition
Image.h:56
Magick::MagickPlusPlusGenesis
Definition
Functions.h:44
Magick++
demo
analyze.cpp
Generated by
1.17.0