* exec/Makefile,
* exec/bw_negate_in_color.cc: new tool.
---
milena/sandbox/ChangeLog | 7 ++++
milena/sandbox/exec/Makefile | 7 ++++
milena/sandbox/exec/bw_negate_in_color.cc | 46 +++++++++++++++++++++++++++++
3 files changed, 60 insertions(+), 0 deletions(-)
create mode 100644 milena/sandbox/exec/Makefile
create mode 100644 milena/sandbox/exec/bw_negate_in_color.cc
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 1290810..11b814e 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,5 +1,12 @@
2009-03-25 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add a small tool to invert b&w in a color image.
+
+ * exec/Makefile,
+ * exec/bw_negate_in_color.cc: new tool.
+
+2009-03-25 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Update Scribo's code.
* scribo/Makefile: add a new target.
diff --git a/milena/sandbox/exec/Makefile b/milena/sandbox/exec/Makefile
new file mode 100644
index 0000000..050d9cd
--- /dev/null
+++ b/milena/sandbox/exec/Makefile
@@ -0,0 +1,7 @@
+TARGET = \
+ bw_negate_in_color
+
+.cc:
+ g++ -I../../ -O1 -DNDEBUG $< -o $@
+
+all: $(TARGET)
diff --git a/milena/sandbox/exec/bw_negate_in_color.cc
b/milena/sandbox/exec/bw_negate_in_color.cc
new file mode 100644
index 0000000..2c69f75
--- /dev/null
+++ b/milena/sandbox/exec/bw_negate_in_color.cc
@@ -0,0 +1,46 @@
+//
+// Invert black and white in a color image.
+//
+
+#include <mln/essential/2d.hh>
+
+namespace mln
+{
+
+ struct bw_negate_in_color
+ : Function_v2v<bw_negate_in_color>
+ {
+ typedef value::rgb8 result;
+
+ value::rgb8 operator()(const value::rgb8& v) const
+ {
+ if (v == literal::white)
+ return literal::black;
+ else if (v == literal::black)
+ return literal::white;
+ else
+ return v;
+ }
+
+ };
+
+}
+
+
+int main(int argc, char *argv[])
+{
+ using namespace mln;
+
+ if (argc < 3)
+ {
+ std::cout << "Usage: " << argv[0] << "
<input.ppm> <out.ppm>"
+ << std::endl;
+ return 1;
+ }
+
+ image2d<value::rgb8> input;
+ io::ppm::load(input, argv[1]);
+
+ bw_negate_in_color f;
+ io::ppm::save(level::transform(input, f), argv[2]);
+}
--
1.5.6.5