Skip to content
Browse files

Update dox for colourmap + add example

Started documenting libCVD with a number of example programs.

These live in examples/

Compile them with make examples
  • Loading branch information...
1 parent 60c25da commit 921871f85436ae8f5e5acbd0c23fe216ee2637dc Edward Rosten committed Mar 21, 2013
Showing with 64 additions and 13 deletions.
  1. +1 −1 Doxyfile
  2. +24 −8 Makefile.in
  3. +12 −4 cvd/{colourmaps.h → colourmap.h}
  4. +27 −0 examples/colourmaps.cc
View
2 Doxyfile
@@ -430,7 +430,7 @@ EXCLUDE_PATTERNS =
# directories that contain example code fragments that are included (see
# the \include command).
-EXAMPLE_PATH =
+EXAMPLE_PATH = examples
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
View
32 Makefile.in
@@ -308,14 +308,6 @@ install-libs-debug-a:libcvd_debug.a
install-libs:$(install_so) install-libs-a
install-libs-debug:$(install_so_debug) install-libs-debug-a
-
-clean:
- /bin/rm -f tmp libcvd.a $(sos) libcvd_debug.a $(dsos) $(dllname) $(ddllname) $(dllimportname) $(ddllimportname)
- find . -name '*.o' | xargs rm -f
- find progs/ -perm +0100 -type f | xargs rm -f
- rm -rf html man
- rm -f regressions/*.out
-
distclean: clean
/bin/rm -f Makefile config.h config.status config.cache config.log cvd/config.h .deps config.dep_tmp
/bin/rm -rf debug
@@ -386,4 +378,28 @@ tests/%.out: tests/%.test
./$< && touch $@
+
+.PHONY: examples
+EXAMPLES=colourmaps
+
+EXAMPLE_PROGS=$(patsubst %,examples/%, $(EXAMPLES))
+
+examples:$(EXAMPLE_PROGS)
+
+$(EXAMPLE_PROGS): % : %.cc
+ $(CXX) -I. $(CPPFLAGS) $(CXXFLAGS) $< -o $@ -O3 -L. -lcvd
+
+
+clean:
+ /bin/rm -f tmp libcvd.a $(sos) libcvd_debug.a $(dsos) $(dllname) $(ddllname) $(dllimportname) $(ddllimportname)
+ find . -name '*.o' | xargs rm -f
+ find progs/ -perm +0100 -type f | xargs rm -f
+ rm -rf html man
+ rm -f regressions/*.out
+ rm -r $(EXAMPLE_PROGS)
+
+
+
+
+
include .deps
View
16 cvd/colourmaps.h → cvd/colourmap.h
@@ -88,27 +88,35 @@ namespace CVD
};
-
template<class C> struct Colourmap;
-
///Handy class for generating a colourscale.
- ///
///Expected range is \f$[0, 1)\f$, and clamping is performed.
///Currently only RGB scales are provided. TODO: RGBA scales.
- ///@ingroup gDraw
+ ///@ingroup gGraphics
+ ///Examples in examples/colourmaps.cc
+ ///@include colourmaps.cc
template<class C> struct Colourmap<Rgb<C> >
{
///Glow/Hot colourscale (red-yellow-white)
+ ///@param d Value in \f$[0, 1)\f$ to map
static Rgb<C> hot(double d) { return Internal::conv<C>(Internal::hot, d);}
///Jet colourscale (red-yellow-green-cyan-blue)
+ ///@param d Value in \f$[0, 1)\f$ to map
static Rgb<C> jet(double d) { return Internal::conv<C>(Internal::jet, d);}
///Green-black-red colourscale
+ ///@param d Value in \f$[0, 1)\f$ to map
static Rgb<C> gkr(double d) { return Internal::conv<C>(Internal::gkr, d);}
};
+
+
+ ///@example colourmaps.cc
+ ///Example of how to use the CVD::Colourmap class for visualisation.
+
+
};
View
27 examples/colourmaps.cc
@@ -0,0 +1,27 @@
+///@example colourmaps.cc
+///Example of how to use the CVD::Colourmap class for visualisation.
+#include <cvd/image_io.h>
+#include <cvd/colourmaps.h>
+using namespace CVD;
+using namespace std;
+
+int main()
+{
+ typedef float C;
+ Image<Rgb<C> > i(ImageRef(256,256));
+
+ //Show three colourmaps side by side from low (top of image)
+ //to high (bottom of image)
+ for(int r=0; r < i.size().y; r++)
+ for(int c=0; c < i.size().x; c++)
+ {
+ if(c < i.size().x / 3.)
+ i[r][c] = Colourmap<Rgb<C> >::hot(r * 1.0/i.size().y);
+ else if(c < i.size().x * 2. / 3.)
+ i[r][c] = Colourmap<Rgb<C> >::jet(r * 1.0/i.size().y);
+ else
+ i[r][c] = Colourmap<Rgb<C> >::gkr(r * 1.0/i.size().y);
+ }
+
+ img_save(i, "colourmaps.png");
+}

0 comments on commit 921871f

Please sign in to comment.
Something went wrong with that request. Please try again.