Merge pull request #4011 from cr333:parula
This commit is contained in:
commit
e0136e39f4
BIN
modules/imgproc/doc/pics/colormaps/colorscale_parula.jpg
Normal file
BIN
modules/imgproc/doc/pics/colormaps/colorscale_parula.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
@ -3741,7 +3741,8 @@ enum ColormapTypes
|
|||||||
COLORMAP_COOL = 8, //!< 
|
COLORMAP_COOL = 8, //!< 
|
||||||
COLORMAP_HSV = 9, //!< 
|
COLORMAP_HSV = 9, //!< 
|
||||||
COLORMAP_PINK = 10, //!< 
|
COLORMAP_PINK = 10, //!< 
|
||||||
COLORMAP_HOT = 11 //!< 
|
COLORMAP_HOT = 11, //!< 
|
||||||
|
COLORMAP_PARULA = 12 //!< 
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @brief Applies a GNU Octave/MATLAB equivalent colormap on a given image.
|
/** @brief Applies a GNU Octave/MATLAB equivalent colormap on a given image.
|
||||||
|
@ -469,6 +469,30 @@ namespace colormap
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Colormap similar to MATLAB's "parula".
|
||||||
|
class Parula : public ColorMap {
|
||||||
|
public:
|
||||||
|
Parula() : ColorMap() {
|
||||||
|
init(256);
|
||||||
|
}
|
||||||
|
|
||||||
|
Parula(int n) : ColorMap() {
|
||||||
|
init(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
void init(int n) {
|
||||||
|
float r[] = { 0.2078, 0.0118, 0.0784, 0.0235, 0.2196, 0.5725, 0.8510, 0.9882, 0.9765 };
|
||||||
|
float g[] = { 0.1647, 0.3882, 0.5216, 0.6549, 0.7255, 0.7490, 0.7294, 0.8078, 0.9843 };
|
||||||
|
float b[] = { 0.5294, 0.8824, 0.8314, 0.7765, 0.6196, 0.4510, 0.3373, 0.1804, 0.0549 };
|
||||||
|
Mat X = linspace(0, 1, 9);
|
||||||
|
this->_lut = ColorMap::linear_colormap(X,
|
||||||
|
Mat(9, 1, CV_32FC1, r).clone(), // red
|
||||||
|
Mat(9, 1, CV_32FC1, g).clone(), // green
|
||||||
|
Mat(9, 1, CV_32FC1, b).clone(), // blue
|
||||||
|
n); // number of sample points
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void ColorMap::operator()(InputArray _src, OutputArray _dst) const
|
void ColorMap::operator()(InputArray _src, OutputArray _dst) const
|
||||||
{
|
{
|
||||||
if(_lut.total() != 256)
|
if(_lut.total() != 256)
|
||||||
@ -513,6 +537,7 @@ namespace colormap
|
|||||||
colormap == COLORMAP_HSV ? (colormap::ColorMap*)(new colormap::HSV) :
|
colormap == COLORMAP_HSV ? (colormap::ColorMap*)(new colormap::HSV) :
|
||||||
colormap == COLORMAP_JET ? (colormap::ColorMap*)(new colormap::Jet) :
|
colormap == COLORMAP_JET ? (colormap::ColorMap*)(new colormap::Jet) :
|
||||||
colormap == COLORMAP_OCEAN ? (colormap::ColorMap*)(new colormap::Ocean) :
|
colormap == COLORMAP_OCEAN ? (colormap::ColorMap*)(new colormap::Ocean) :
|
||||||
|
colormap == COLORMAP_PARULA ? (colormap::ColorMap*)(new colormap::Parula) :
|
||||||
colormap == COLORMAP_PINK ? (colormap::ColorMap*)(new colormap::Pink) :
|
colormap == COLORMAP_PINK ? (colormap::ColorMap*)(new colormap::Pink) :
|
||||||
colormap == COLORMAP_RAINBOW ? (colormap::ColorMap*)(new colormap::Rainbow) :
|
colormap == COLORMAP_RAINBOW ? (colormap::ColorMap*)(new colormap::Rainbow) :
|
||||||
colormap == COLORMAP_SPRING ? (colormap::ColorMap*)(new colormap::Spring) :
|
colormap == COLORMAP_SPRING ? (colormap::ColorMap*)(new colormap::Spring) :
|
||||||
|
Loading…
x
Reference in New Issue
Block a user