opencv on mbed

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

ColorMaps in OpenCV

ColorMaps in OpenCV
[Image processing]

The human perception isn't built for observing fine changes in grayscale images. More...

Enumerations

enum  ColormapTypes {
  COLORMAP_AUTUMN = 0, COLORMAP_BONE = 1, COLORMAP_JET = 2, COLORMAP_WINTER = 3,
  COLORMAP_RAINBOW = 4, COLORMAP_OCEAN = 5, COLORMAP_SUMMER = 6, COLORMAP_SPRING = 7,
  COLORMAP_COOL = 8, COLORMAP_HSV = 9, COLORMAP_PINK = 10, COLORMAP_HOT = 11,
  COLORMAP_PARULA = 12
}
 

GNU Octave/MATLAB equivalent colormaps.

More...

Functions

CV_EXPORTS_W void applyColorMap (InputArray src, OutputArray dst, int colormap)
 Applies a GNU Octave/MATLAB equivalent colormap on a given image.

Detailed Description

The human perception isn't built for observing fine changes in grayscale images.

Human eyes are more sensitive to observing changes between colors, so you often need to recolor your grayscale images to get a clue about them. OpenCV now comes with various colormaps to enhance the visualization in your computer vision application.

In OpenCV you only need applyColorMap to apply a colormap on a given image. The following sample code reads the path to an image from command line, applies a Jet colormap on it and shows the result:

#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
using namespace cv;

#include <iostream>
using namespace std;

int main(int argc, const char *argv[])
{
    // We need an input image. (can be grayscale or color)
    if (argc < 2)
    {
        cerr << "We need an image to process here. Please run: colorMap [path_to_image]" << endl;
        return -1;
    }
    Mat img_in = imread(argv[1]);
    if(img_in.empty())
    {
        cerr << "Sample image (" << argv[1] << ") is empty. Please adjust your path, so it points to a valid input image!" << endl;
        return -1;
    }
    // Holds the colormap version of the image:
    Mat img_color;
    // Apply the colormap:
    applyColorMap(img_in, img_color, COLORMAP_JET);
    // Show the result:
    imshow("colorMap", img_color);
    waitKey(0);
    return 0;
}
See also:
cv::ColormapTypes

Enumeration Type Documentation

enum ColormapTypes

GNU Octave/MATLAB equivalent colormaps.

Enumerator:
COLORMAP_AUTUMN 

![autumn](pics/colormaps/colorscale_autumn.jpg)

COLORMAP_BONE 

![bone](pics/colormaps/colorscale_bone.jpg)

COLORMAP_JET 

![jet](pics/colormaps/colorscale_jet.jpg)

COLORMAP_WINTER 

![winter](pics/colormaps/colorscale_winter.jpg)

COLORMAP_RAINBOW 

![rainbow](pics/colormaps/colorscale_rainbow.jpg)

COLORMAP_OCEAN 

![ocean](pics/colormaps/colorscale_ocean.jpg)

COLORMAP_SUMMER 

![summer](pics/colormaps/colorscale_summer.jpg)

COLORMAP_SPRING 

![spring](pics/colormaps/colorscale_spring.jpg)

COLORMAP_COOL 

![cool](pics/colormaps/colorscale_cool.jpg)

COLORMAP_HSV 

![HSV](pics/colormaps/colorscale_hsv.jpg)

COLORMAP_PINK 

![pink](pics/colormaps/colorscale_pink.jpg)

COLORMAP_HOT 

![hot](pics/colormaps/colorscale_hot.jpg)

COLORMAP_PARULA 

![parula](pics/colormaps/colorscale_parula.jpg)

Definition at line 3780 of file imgproc.hpp.


Function Documentation

CV_EXPORTS_W void cv::applyColorMap ( InputArray  src,
OutputArray  dst,
int  colormap 
)

Applies a GNU Octave/MATLAB equivalent colormap on a given image.

Parameters:
srcThe source image, grayscale or colored does not matter.
dstThe result is the colormapped source image. Note: Mat::create is called on dst.
colormapThe colormap to apply, see cv::ColormapTypes