greyscale image colormap [patch]

Hi,

I wrote a simple greyscale image colormap. Thought you might be interested :slight_smile:

It’s not really clean, but it does what I need.

Here’s the patch to palabos:


# HG changeset patch
# User arne@brand.medma
# Date 1276505021 -7200
# Branch babtests
# Node ID 87a577c922aa66a93d282b6f7c3e2b8e0363fc00
# Parent  4fe639a63a13fb937417a5eb228db924a5905e56
Added greyscale output

diff -r 4fe639a63a13 -r 87a577c922aa src/io/colormaps.cpp
--- a/src/io/colormaps.cpp	Do Jun 10 17:43:00 2010 +0200
+++ b/src/io/colormaps.cpp	Mo Jun 14 10:43:41 2010 +0200
@@ -324,6 +324,25 @@
     return leeLooBlue;
 }
 
+PiecewiseFunction generateGreyRGB() {
+    double p0  =  0.;
+    double p2  =  3./8.;
+    double p3  =  5./8.;
+    double p4  =  7./8.;
+    double p5  =  1.;
+    double p6  =  9./8.;
+
+
+    PiecewiseFunction greyRGB;
+    greyRGB.addPiece (Piece(p0, p2), new LinearFunction(p0, p2, 1., 0.3) );
+    greyRGB.addPiece (Piece(p2, p3), new LinearFunction(p2, p3, 0.3, 0.2) );
+    greyRGB.addPiece (Piece(p3, p4), new LinearFunction(p3, p4, 0.2, 0.1) );
+    greyRGB.addPiece (Piece(p4, p5), new LinearFunction(p4, p6, 0.1, 0.) );
+
+    return greyRGB;
+}
+
+
 ColorMap generateMap(std::string mapName) {
     if (mapName == "earth") {
         return ColorMap (
@@ -355,6 +374,12 @@
                 generateLeeLooGreen(),
                 generateLeeLooBlue() );
     }
+    else if (mapName == "grey") {
+        return ColorMap (
+                generateGreyRGB(),
+                generateGreyRGB(),
+                generateGreyRGB() );
+    }
     return ColorMap (
             generateLeeLooRed(),
             generateLeeLooGreen(),


Copyright: 2010 Arne Babenhauserheide
License: GPLv3+

I’d be happy, if you’d include it.

Could you give me a status, if you will include the grey colormap patch? I’d prefer to not have to track it myself :slight_smile:

Sorry to nag, but I’d really like to know the status. Will you take the greyscale patch? Aside from the hg header (which patch ignores) it is simply a straightforward patch, but it took me some time to get it beautiful.