Merge remote-tracking branch 'master' into stitch-fix
* 'master' of github.com:itseez/opencv: (82 commits)
moved part of video to contrib/{outflow, bgsegm}; moved matlab to contrib
added some basic functionality needed by the new face module (moved from the old "contrib")
moved to the new opencv_contrib/face module
fixed various warnings and obvious errors reported by clang compiler and the coverity tool.
Fixed review comment from Vadim Pisarevsky
modified farneback sample to use T-API
ECC patch by the author (G. Evangelidis); fixed some OCL Farneback optical flow test failures on Mac
small fix for GaussianBlur ocl test
fix binary package build
small fix for ocl_resize
fix IOS framework
fixed test ocl_MatchTemplate for sparse matrix
Fixed typos
fixing error, wrong template method param.
fixing Mac build
some formal changes (generally adding constness)
Fixed choice of kercn and rowsPerWI for non-Intel device.
fixed nDiffs for CalcBackProject
fixed tests for ocl_filter2d, ocl_matchTemplate, ocl_histogram.cpp
Fixed issue: Mat::copyTo(UMat) if device copy is obsolete. Added test.
...
Conflicts:
modules/core/include/opencv2/core/mat.inl.hpp
@@ -0,0 +1,107 @@
|
||||
ColorMaps in OpenCV
|
||||
===================
|
||||
|
||||
applyColorMap
|
||||
---------------------
|
||||
|
||||
Applies a GNU Octave/MATLAB equivalent colormap on a given image.
|
||||
|
||||
.. ocv:function:: void applyColorMap(InputArray src, OutputArray dst, int colormap)
|
||||
|
||||
:param src: The source image, grayscale or colored does not matter.
|
||||
:param dst: The result is the colormapped source image. Note: :ocv:func:`Mat::create` is called on dst.
|
||||
:param colormap: The colormap to apply, see the list of available colormaps below.
|
||||
|
||||
Currently the following GNU Octave/MATLAB equivalent colormaps are implemented:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
enum
|
||||
{
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
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 2.4 you only need :ocv:func:`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:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
#include <opencv2/contrib.hpp>
|
||||
#include <opencv2/core.hpp>
|
||||
#include <opencv2/highgui.hpp>
|
||||
|
||||
using namespace cv;
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
// Get the path to the image, if it was given
|
||||
// if no arguments were given.
|
||||
String filename;
|
||||
if (argc > 1) {
|
||||
filename = String(argv[1]);
|
||||
}
|
||||
// The following lines show how to apply a colormap on a given image
|
||||
// and show it with cv::imshow example with an image. An exception is
|
||||
// thrown if the path to the image is invalid.
|
||||
if(!filename.empty()) {
|
||||
Mat img0 = imread(filename);
|
||||
// Throw an exception, if the image can't be read:
|
||||
if(img0.empty()) {
|
||||
CV_Error(CV_StsBadArg, "Sample image is empty. Please adjust your path, so it points to a valid input image!");
|
||||
}
|
||||
// Holds the colormap version of the image:
|
||||
Mat cm_img0;
|
||||
// Apply the colormap:
|
||||
applyColorMap(img0, cm_img0, COLORMAP_JET);
|
||||
// Show the result:
|
||||
imshow("cm_img0", cm_img0);
|
||||
waitKey(0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
And here are the color scales for each of the available colormaps:
|
||||
|
||||
+-----------------------+---------------------------------------------------+
|
||||
| Class | Scale |
|
||||
+=======================+===================================================+
|
||||
| COLORMAP_AUTUMN | .. image:: pics/colormaps/colorscale_autumn.jpg |
|
||||
+-----------------------+---------------------------------------------------+
|
||||
| COLORMAP_BONE | .. image:: pics/colormaps/colorscale_bone.jpg |
|
||||
+-----------------------+---------------------------------------------------+
|
||||
| COLORMAP_COOL | .. image:: pics/colormaps/colorscale_cool.jpg |
|
||||
+-----------------------+---------------------------------------------------+
|
||||
| COLORMAP_HOT | .. image:: pics/colormaps/colorscale_hot.jpg |
|
||||
+-----------------------+---------------------------------------------------+
|
||||
| COLORMAP_HSV | .. image:: pics/colormaps/colorscale_hsv.jpg |
|
||||
+-----------------------+---------------------------------------------------+
|
||||
| COLORMAP_JET | .. image:: pics/colormaps/colorscale_jet.jpg |
|
||||
+-----------------------+---------------------------------------------------+
|
||||
| COLORMAP_OCEAN | .. image:: pics/colormaps/colorscale_ocean.jpg |
|
||||
+-----------------------+---------------------------------------------------+
|
||||
| COLORMAP_PINK | .. image:: pics/colormaps/colorscale_pink.jpg |
|
||||
+-----------------------+---------------------------------------------------+
|
||||
| COLORMAP_RAINBOW | .. image:: pics/colormaps/colorscale_rainbow.jpg |
|
||||
+-----------------------+---------------------------------------------------+
|
||||
| COLORMAP_SPRING | .. image:: pics/colormaps/colorscale_spring.jpg |
|
||||
+-----------------------+---------------------------------------------------+
|
||||
| COLORMAP_SUMMER | .. image:: pics/colormaps/colorscale_summer.jpg |
|
||||
+-----------------------+---------------------------------------------------+
|
||||
| COLORMAP_WINTER | .. image:: pics/colormaps/colorscale_winter.jpg |
|
||||
+-----------------------+---------------------------------------------------+
|
||||
@@ -10,6 +10,7 @@ imgproc. Image Processing
|
||||
filtering
|
||||
geometric_transformations
|
||||
miscellaneous_transformations
|
||||
colormaps
|
||||
histograms
|
||||
structural_analysis_and_shape_descriptors
|
||||
motion_analysis_and_object_tracking
|
||||
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
@@ -1518,6 +1518,24 @@ CV_EXPORTS Ptr<GeneralizedHoughGuil> createGeneralizedHoughGuil();
|
||||
//! Performs linear blending of two images
|
||||
CV_EXPORTS void blendLinear(InputArray src1, InputArray src2, InputArray weights1, InputArray weights2, OutputArray dst);
|
||||
|
||||
enum
|
||||
{
|
||||
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
|
||||
};
|
||||
|
||||
CV_EXPORTS_W void applyColorMap(InputArray src, OutputArray dst, int colormap);
|
||||
|
||||
} // cv
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_perf.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_perf.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_perf.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_perf.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_perf.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_perf.hpp"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_perf.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_perf.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "perf_precomp.hpp"
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_perf.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_perf.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
#include "../perf_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_perf.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencl_kernels.hpp"
|
||||
#include "opencl_kernels_imgproc.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencl_kernels.hpp"
|
||||
#include "opencl_kernels_imgproc.hpp"
|
||||
|
||||
namespace cv {
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencl_kernels.hpp"
|
||||
#include "opencl_kernels_imgproc.hpp"
|
||||
|
||||
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencl_kernels.hpp"
|
||||
#include "opencl_kernels_imgproc.hpp"
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// CLAHE
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
\**********************************************************************************/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencl_kernels.hpp"
|
||||
#include "opencl_kernels_imgproc.hpp"
|
||||
#include <limits>
|
||||
|
||||
#define CV_DESCALE(x,n) (((x) + (1 << ((n)-1))) >> (n))
|
||||
@@ -2038,6 +2038,10 @@ struct Luv2RGB_f
|
||||
float G = X*C3 + Y*C4 + Z*C5;
|
||||
float B = X*C6 + Y*C7 + Z*C8;
|
||||
|
||||
R = std::min(std::max(R, 0.f), 1.f);
|
||||
G = std::min(std::max(G, 0.f), 1.f);
|
||||
B = std::min(std::max(B, 0.f), 1.f);
|
||||
|
||||
if( gammaTab )
|
||||
{
|
||||
R = splineInterpolate(R*gscale, gammaTab, GAMMA_TAB_SIZE);
|
||||
|
||||
@@ -0,0 +1,530 @@
|
||||
/*
|
||||
* Copyright (c) 2011. Philipp Wagner <bytefish[at]gmx[dot]de>.
|
||||
* Released to public domain under terms of the BSD Simplified license.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the organization nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* See <http://www.opensource.org/licenses/bsd-license>
|
||||
*/
|
||||
#include "precomp.hpp"
|
||||
#include <iostream>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning( disable: 4305 )
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
static Mat linspace(float x0, float x1, int n)
|
||||
{
|
||||
Mat pts(n, 1, CV_32FC1);
|
||||
float step = (x1-x0)/(n-1);
|
||||
for(int i = 0; i < n; i++)
|
||||
pts.at<float>(i,0) = x0+i*step;
|
||||
return pts;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// cv::sortMatrixRowsByIndices
|
||||
//------------------------------------------------------------------------------
|
||||
static void sortMatrixRowsByIndices(InputArray _src, InputArray _indices, OutputArray _dst)
|
||||
{
|
||||
if(_indices.getMat().type() != CV_32SC1)
|
||||
CV_Error(Error::StsUnsupportedFormat, "cv::sortRowsByIndices only works on integer indices!");
|
||||
Mat src = _src.getMat();
|
||||
std::vector<int> indices = _indices.getMat();
|
||||
_dst.create(src.rows, src.cols, src.type());
|
||||
Mat dst = _dst.getMat();
|
||||
for(size_t idx = 0; idx < indices.size(); idx++) {
|
||||
Mat originalRow = src.row(indices[idx]);
|
||||
Mat sortedRow = dst.row((int)idx);
|
||||
originalRow.copyTo(sortedRow);
|
||||
}
|
||||
}
|
||||
|
||||
static Mat sortMatrixRowsByIndices(InputArray src, InputArray indices)
|
||||
{
|
||||
Mat dst;
|
||||
sortMatrixRowsByIndices(src, indices, dst);
|
||||
return dst;
|
||||
}
|
||||
|
||||
|
||||
static Mat argsort(InputArray _src, bool ascending=true)
|
||||
{
|
||||
Mat src = _src.getMat();
|
||||
if (src.rows != 1 && src.cols != 1)
|
||||
CV_Error(Error::StsBadArg, "cv::argsort only sorts 1D matrices.");
|
||||
int flags = SORT_EVERY_ROW | (ascending ? SORT_ASCENDING : SORT_DESCENDING);
|
||||
Mat sorted_indices;
|
||||
sortIdx(src.reshape(1,1),sorted_indices,flags);
|
||||
return sorted_indices;
|
||||
}
|
||||
|
||||
template <typename _Tp> static
|
||||
Mat interp1_(const Mat& X_, const Mat& Y_, const Mat& XI)
|
||||
{
|
||||
int n = XI.rows;
|
||||
// sort input table
|
||||
std::vector<int> sort_indices = argsort(X_);
|
||||
|
||||
Mat X = sortMatrixRowsByIndices(X_,sort_indices);
|
||||
Mat Y = sortMatrixRowsByIndices(Y_,sort_indices);
|
||||
// interpolated values
|
||||
Mat yi = Mat::zeros(XI.size(), XI.type());
|
||||
for(int i = 0; i < n; i++) {
|
||||
int c = 0;
|
||||
int low = 0;
|
||||
int high = X.rows - 1;
|
||||
// set bounds
|
||||
if(XI.at<_Tp>(i,0) < X.at<_Tp>(low, 0))
|
||||
high = 1;
|
||||
if(XI.at<_Tp>(i,0) > X.at<_Tp>(high, 0))
|
||||
low = high - 1;
|
||||
// binary search
|
||||
while((high-low)>1) {
|
||||
c = low + ((high - low) >> 1);
|
||||
if(XI.at<_Tp>(i,0) > X.at<_Tp>(c,0)) {
|
||||
low = c;
|
||||
} else {
|
||||
high = c;
|
||||
}
|
||||
}
|
||||
// linear interpolation
|
||||
yi.at<_Tp>(i,0) += Y.at<_Tp>(low,0)
|
||||
+ (XI.at<_Tp>(i,0) - X.at<_Tp>(low,0))
|
||||
* (Y.at<_Tp>(high,0) - Y.at<_Tp>(low,0))
|
||||
/ (X.at<_Tp>(high,0) - X.at<_Tp>(low,0));
|
||||
}
|
||||
return yi;
|
||||
}
|
||||
|
||||
static Mat interp1(InputArray _x, InputArray _Y, InputArray _xi)
|
||||
{
|
||||
// get matrices
|
||||
Mat x = _x.getMat();
|
||||
Mat Y = _Y.getMat();
|
||||
Mat xi = _xi.getMat();
|
||||
// check types & alignment
|
||||
CV_Assert((x.type() == Y.type()) && (Y.type() == xi.type()));
|
||||
CV_Assert((x.cols == 1) && (x.rows == Y.rows) && (x.cols == Y.cols));
|
||||
// call templated interp1
|
||||
switch(x.type()) {
|
||||
case CV_8SC1: return interp1_<char>(x,Y,xi); break;
|
||||
case CV_8UC1: return interp1_<unsigned char>(x,Y,xi); break;
|
||||
case CV_16SC1: return interp1_<short>(x,Y,xi); break;
|
||||
case CV_16UC1: return interp1_<unsigned short>(x,Y,xi); break;
|
||||
case CV_32SC1: return interp1_<int>(x,Y,xi); break;
|
||||
case CV_32FC1: return interp1_<float>(x,Y,xi); break;
|
||||
case CV_64FC1: return interp1_<double>(x,Y,xi); break;
|
||||
default: CV_Error(Error::StsUnsupportedFormat, ""); break;
|
||||
}
|
||||
return Mat();
|
||||
}
|
||||
|
||||
namespace colormap
|
||||
{
|
||||
|
||||
class ColorMap {
|
||||
|
||||
protected:
|
||||
Mat _lut;
|
||||
|
||||
public:
|
||||
virtual ~ColorMap() {}
|
||||
|
||||
// Applies the colormap on a given image.
|
||||
//
|
||||
// This function expects BGR-aligned data of type CV_8UC1 or
|
||||
// CV_8UC3. If the wrong image type is given, the original image
|
||||
// will be returned.
|
||||
//
|
||||
// Throws an error for wrong-aligned lookup table, which must be
|
||||
// of size 256 in the latest OpenCV release (2.3.1).
|
||||
void operator()(InputArray src, OutputArray dst) const;
|
||||
|
||||
// Setup base map to interpolate from.
|
||||
virtual void init(int n) = 0;
|
||||
|
||||
// Interpolates from a base colormap.
|
||||
static Mat linear_colormap(InputArray X,
|
||||
InputArray r, InputArray g, InputArray b,
|
||||
int n) {
|
||||
return linear_colormap(X,r,g,b,linspace(0,1,n));
|
||||
}
|
||||
|
||||
// Interpolates from a base colormap.
|
||||
static Mat linear_colormap(InputArray X,
|
||||
InputArray r, InputArray g, InputArray b,
|
||||
float begin, float end, float n) {
|
||||
return linear_colormap(X,r,g,b,linspace(begin,end, cvRound(n)));
|
||||
}
|
||||
|
||||
// Interpolates from a base colormap.
|
||||
static Mat linear_colormap(InputArray X,
|
||||
InputArray r, InputArray g, InputArray b,
|
||||
InputArray xi);
|
||||
};
|
||||
|
||||
// Equals the GNU Octave colormap "autumn".
|
||||
class Autumn : public ColorMap {
|
||||
public:
|
||||
Autumn() : ColorMap() {
|
||||
init(256);
|
||||
}
|
||||
|
||||
Autumn(int n) : ColorMap() {
|
||||
init(n);
|
||||
}
|
||||
|
||||
void init(int n) {
|
||||
float r[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
float g[] = { 0, 0.01587301587301587, 0.03174603174603174, 0.04761904761904762, 0.06349206349206349, 0.07936507936507936, 0.09523809523809523, 0.1111111111111111, 0.126984126984127, 0.1428571428571428, 0.1587301587301587, 0.1746031746031746, 0.1904761904761905, 0.2063492063492063, 0.2222222222222222, 0.2380952380952381, 0.253968253968254, 0.2698412698412698, 0.2857142857142857, 0.3015873015873016, 0.3174603174603174, 0.3333333333333333, 0.3492063492063492, 0.3650793650793651, 0.3809523809523809, 0.3968253968253968, 0.4126984126984127, 0.4285714285714285, 0.4444444444444444, 0.4603174603174603, 0.4761904761904762, 0.492063492063492, 0.5079365079365079, 0.5238095238095238, 0.5396825396825397, 0.5555555555555556, 0.5714285714285714, 0.5873015873015873, 0.6031746031746031, 0.6190476190476191, 0.6349206349206349, 0.6507936507936508, 0.6666666666666666, 0.6825396825396826, 0.6984126984126984, 0.7142857142857143, 0.7301587301587301, 0.746031746031746, 0.7619047619047619, 0.7777777777777778, 0.7936507936507936, 0.8095238095238095, 0.8253968253968254, 0.8412698412698413, 0.8571428571428571, 0.873015873015873, 0.8888888888888888, 0.9047619047619048, 0.9206349206349206, 0.9365079365079365, 0.9523809523809523, 0.9682539682539683, 0.9841269841269841, 1};
|
||||
float b[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
Mat X = linspace(0,1,64);
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
Mat(64,1, CV_32FC1, r).clone(), // red
|
||||
Mat(64,1, CV_32FC1, g).clone(), // green
|
||||
Mat(64,1, CV_32FC1, b).clone(), // blue
|
||||
n); // number of sample points
|
||||
}
|
||||
};
|
||||
|
||||
// Equals the GNU Octave colormap "bone".
|
||||
class Bone : public ColorMap {
|
||||
public:
|
||||
Bone() : ColorMap() {
|
||||
init(256);
|
||||
}
|
||||
|
||||
Bone(int n) : ColorMap() {
|
||||
init(n);
|
||||
}
|
||||
|
||||
void init(int n) {
|
||||
float r[] = { 0, 0.01388888888888889, 0.02777777777777778, 0.04166666666666666, 0.05555555555555555, 0.06944444444444445, 0.08333333333333333, 0.09722222222222221, 0.1111111111111111, 0.125, 0.1388888888888889, 0.1527777777777778, 0.1666666666666667, 0.1805555555555556, 0.1944444444444444, 0.2083333333333333, 0.2222222222222222, 0.2361111111111111, 0.25, 0.2638888888888889, 0.2777777777777778, 0.2916666666666666, 0.3055555555555555, 0.3194444444444444, 0.3333333333333333, 0.3472222222222222, 0.3611111111111111, 0.375, 0.3888888888888888, 0.4027777777777777, 0.4166666666666666, 0.4305555555555555, 0.4444444444444444, 0.4583333333333333, 0.4722222222222222, 0.4861111111111112, 0.5, 0.5138888888888888, 0.5277777777777778, 0.5416666666666667, 0.5555555555555556, 0.5694444444444444, 0.5833333333333333, 0.5972222222222222, 0.611111111111111, 0.6249999999999999, 0.6388888888888888, 0.6527777777777778, 0.6726190476190474, 0.6944444444444442, 0.7162698412698412, 0.7380952380952381, 0.7599206349206349, 0.7817460317460316, 0.8035714285714286, 0.8253968253968254, 0.8472222222222221, 0.8690476190476188, 0.8908730158730158, 0.9126984126984128, 0.9345238095238095, 0.9563492063492063, 0.978174603174603, 1};
|
||||
float g[] = { 0, 0.01388888888888889, 0.02777777777777778, 0.04166666666666666, 0.05555555555555555, 0.06944444444444445, 0.08333333333333333, 0.09722222222222221, 0.1111111111111111, 0.125, 0.1388888888888889, 0.1527777777777778, 0.1666666666666667, 0.1805555555555556, 0.1944444444444444, 0.2083333333333333, 0.2222222222222222, 0.2361111111111111, 0.25, 0.2638888888888889, 0.2777777777777778, 0.2916666666666666, 0.3055555555555555, 0.3194444444444444, 0.3353174603174602, 0.3544973544973544, 0.3736772486772486, 0.3928571428571428, 0.412037037037037, 0.4312169312169312, 0.4503968253968254, 0.4695767195767195, 0.4887566137566137, 0.5079365079365078, 0.5271164021164021, 0.5462962962962963, 0.5654761904761904, 0.5846560846560845, 0.6038359788359787, 0.623015873015873, 0.6421957671957671, 0.6613756613756612, 0.6805555555555555, 0.6997354497354497, 0.7189153439153438, 0.7380952380952379, 0.7572751322751322, 0.7764550264550264, 0.7916666666666666, 0.8055555555555555, 0.8194444444444444, 0.8333333333333334, 0.8472222222222222, 0.861111111111111, 0.875, 0.8888888888888888, 0.9027777777777777, 0.9166666666666665, 0.9305555555555555, 0.9444444444444444, 0.9583333333333333, 0.9722222222222221, 0.986111111111111, 1};
|
||||
float b[] = { 0, 0.01917989417989418, 0.03835978835978836, 0.05753968253968253, 0.07671957671957672, 0.09589947089947089, 0.1150793650793651, 0.1342592592592592, 0.1534391534391534, 0.1726190476190476, 0.1917989417989418, 0.210978835978836, 0.2301587301587301, 0.2493386243386243, 0.2685185185185185, 0.2876984126984127, 0.3068783068783069, 0.326058201058201, 0.3452380952380952, 0.3644179894179894, 0.3835978835978835, 0.4027777777777777, 0.4219576719576719, 0.4411375661375661, 0.4583333333333333, 0.4722222222222222, 0.4861111111111111, 0.5, 0.5138888888888888, 0.5277777777777777, 0.5416666666666666, 0.5555555555555556, 0.5694444444444444, 0.5833333333333333, 0.5972222222222222, 0.6111111111111112, 0.625, 0.6388888888888888, 0.6527777777777778, 0.6666666666666667, 0.6805555555555556, 0.6944444444444444, 0.7083333333333333, 0.7222222222222222, 0.736111111111111, 0.7499999999999999, 0.7638888888888888, 0.7777777777777778, 0.7916666666666666, 0.8055555555555555, 0.8194444444444444, 0.8333333333333334, 0.8472222222222222, 0.861111111111111, 0.875, 0.8888888888888888, 0.9027777777777777, 0.9166666666666665, 0.9305555555555555, 0.9444444444444444, 0.9583333333333333, 0.9722222222222221, 0.986111111111111, 1};
|
||||
Mat X = linspace(0,1,64);
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
Mat(64,1, CV_32FC1, r).clone(), // red
|
||||
Mat(64,1, CV_32FC1, g).clone(), // green
|
||||
Mat(64,1, CV_32FC1, b).clone(), // blue
|
||||
n); // number of sample points
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// Equals the GNU Octave colormap "jet".
|
||||
class Jet : public ColorMap {
|
||||
|
||||
public:
|
||||
Jet() {
|
||||
init(256);
|
||||
}
|
||||
Jet(int n) : ColorMap() {
|
||||
init(n);
|
||||
}
|
||||
|
||||
void init(int n) {
|
||||
// breakpoints
|
||||
Mat X = linspace(0,1,256);
|
||||
// define the basemap
|
||||
float r[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00588235294117645,0.02156862745098032,0.03725490196078418,0.05294117647058827,0.06862745098039214,0.084313725490196,0.1000000000000001,0.115686274509804,0.1313725490196078,0.1470588235294117,0.1627450980392156,0.1784313725490196,0.1941176470588235,0.2098039215686274,0.2254901960784315,0.2411764705882353,0.2568627450980392,0.2725490196078431,0.2882352941176469,0.303921568627451,0.3196078431372549,0.3352941176470587,0.3509803921568628,0.3666666666666667,0.3823529411764706,0.3980392156862744,0.4137254901960783,0.4294117647058824,0.4450980392156862,0.4607843137254901,0.4764705882352942,0.4921568627450981,0.5078431372549019,0.5235294117647058,0.5392156862745097,0.5549019607843135,0.5705882352941174,0.5862745098039217,0.6019607843137256,0.6176470588235294,0.6333333333333333,0.6490196078431372,0.664705882352941,0.6803921568627449,0.6960784313725492,0.7117647058823531,0.7274509803921569,0.7431372549019608,0.7588235294117647,0.7745098039215685,0.7901960784313724,0.8058823529411763,0.8215686274509801,0.8372549019607844,0.8529411764705883,0.8686274509803922,0.884313725490196,0.8999999999999999,0.9156862745098038,0.9313725490196076,0.947058823529412,0.9627450980392158,0.9784313725490197,0.9941176470588236,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0.9862745098039216,0.9705882352941178,0.9549019607843139,0.93921568627451,0.9235294117647062,0.9078431372549018,0.892156862745098,0.8764705882352941,0.8607843137254902,0.8450980392156864,0.8294117647058825,0.8137254901960786,0.7980392156862743,0.7823529411764705,0.7666666666666666,0.7509803921568627,0.7352941176470589,0.719607843137255,0.7039215686274511,0.6882352941176473,0.6725490196078434,0.6568627450980391,0.6411764705882352,0.6254901960784314,0.6098039215686275,0.5941176470588236,0.5784313725490198,0.5627450980392159,0.5470588235294116,0.5313725490196077,0.5156862745098039,0.5};
|
||||
float g[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.001960784313725483,0.01764705882352935,0.03333333333333333,0.0490196078431373,0.06470588235294117,0.08039215686274503,0.09607843137254901,0.111764705882353,0.1274509803921569,0.1431372549019607,0.1588235294117647,0.1745098039215687,0.1901960784313725,0.2058823529411764,0.2215686274509804,0.2372549019607844,0.2529411764705882,0.2686274509803921,0.2843137254901961,0.3,0.3156862745098039,0.3313725490196078,0.3470588235294118,0.3627450980392157,0.3784313725490196,0.3941176470588235,0.4098039215686274,0.4254901960784314,0.4411764705882353,0.4568627450980391,0.4725490196078431,0.4882352941176471,0.503921568627451,0.5196078431372548,0.5352941176470587,0.5509803921568628,0.5666666666666667,0.5823529411764705,0.5980392156862746,0.6137254901960785,0.6294117647058823,0.6450980392156862,0.6607843137254901,0.6764705882352942,0.692156862745098,0.7078431372549019,0.723529411764706,0.7392156862745098,0.7549019607843137,0.7705882352941176,0.7862745098039214,0.8019607843137255,0.8176470588235294,0.8333333333333333,0.8490196078431373,0.8647058823529412,0.8803921568627451,0.8960784313725489,0.9117647058823528,0.9274509803921569,0.9431372549019608,0.9588235294117646,0.9745098039215687,0.9901960784313726,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0.9901960784313726,0.9745098039215687,0.9588235294117649,0.943137254901961,0.9274509803921571,0.9117647058823528,0.8960784313725489,0.8803921568627451,0.8647058823529412,0.8490196078431373,0.8333333333333335,0.8176470588235296,0.8019607843137253,0.7862745098039214,0.7705882352941176,0.7549019607843137,0.7392156862745098,0.723529411764706,0.7078431372549021,0.6921568627450982,0.6764705882352944,0.6607843137254901,0.6450980392156862,0.6294117647058823,0.6137254901960785,0.5980392156862746,0.5823529411764707,0.5666666666666669,0.5509803921568626,0.5352941176470587,0.5196078431372548,0.503921568627451,0.4882352941176471,0.4725490196078432,0.4568627450980394,0.4411764705882355,0.4254901960784316,0.4098039215686273,0.3941176470588235,0.3784313725490196,0.3627450980392157,0.3470588235294119,0.331372549019608,0.3156862745098041,0.2999999999999998,0.284313725490196,0.2686274509803921,0.2529411764705882,0.2372549019607844,0.2215686274509805,0.2058823529411766,0.1901960784313728,0.1745098039215689,0.1588235294117646,0.1431372549019607,0.1274509803921569,0.111764705882353,0.09607843137254912,0.08039215686274526,0.06470588235294139,0.04901960784313708,0.03333333333333321,0.01764705882352935,0.001960784313725483,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
float b[] = {0.5,0.5156862745098039,0.5313725490196078,0.5470588235294118,0.5627450980392157,0.5784313725490196,0.5941176470588235,0.6098039215686275,0.6254901960784314,0.6411764705882352,0.6568627450980392,0.6725490196078432,0.6882352941176471,0.7039215686274509,0.7196078431372549,0.7352941176470589,0.7509803921568627,0.7666666666666666,0.7823529411764706,0.7980392156862746,0.8137254901960784,0.8294117647058823,0.8450980392156863,0.8607843137254902,0.8764705882352941,0.892156862745098,0.907843137254902,0.9235294117647059,0.9392156862745098,0.9549019607843137,0.9705882352941176,0.9862745098039216,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0.9941176470588236,0.9784313725490197,0.9627450980392158,0.9470588235294117,0.9313725490196079,0.915686274509804,0.8999999999999999,0.884313725490196,0.8686274509803922,0.8529411764705883,0.8372549019607844,0.8215686274509804,0.8058823529411765,0.7901960784313726,0.7745098039215685,0.7588235294117647,0.7431372549019608,0.7274509803921569,0.7117647058823531,0.696078431372549,0.6803921568627451,0.6647058823529413,0.6490196078431372,0.6333333333333333,0.6176470588235294,0.6019607843137256,0.5862745098039217,0.5705882352941176,0.5549019607843138,0.5392156862745099,0.5235294117647058,0.5078431372549019,0.4921568627450981,0.4764705882352942,0.4607843137254903,0.4450980392156865,0.4294117647058826,0.4137254901960783,0.3980392156862744,0.3823529411764706,0.3666666666666667,0.3509803921568628,0.335294117647059,0.3196078431372551,0.3039215686274508,0.2882352941176469,0.2725490196078431,0.2568627450980392,0.2411764705882353,0.2254901960784315,0.2098039215686276,0.1941176470588237,0.1784313725490199,0.1627450980392156,0.1470588235294117,0.1313725490196078,0.115686274509804,0.1000000000000001,0.08431372549019622,0.06862745098039236,0.05294117647058805,0.03725490196078418,0.02156862745098032,0.00588235294117645,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
// now build lookup table
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
Mat(256,1, CV_32FC1, r).clone(), // red
|
||||
Mat(256,1, CV_32FC1, g).clone(), // green
|
||||
Mat(256,1, CV_32FC1, b).clone(), // blue
|
||||
n);
|
||||
}
|
||||
};
|
||||
|
||||
// Equals the GNU Octave colormap "winter".
|
||||
class Winter : public ColorMap {
|
||||
public:
|
||||
Winter() : ColorMap() {
|
||||
init(256);
|
||||
}
|
||||
|
||||
Winter(int n) : ColorMap() {
|
||||
init(n);
|
||||
}
|
||||
|
||||
void init(int n) {
|
||||
float r[] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
||||
float g[] = {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0};
|
||||
float b[] = {1.0, 0.95, 0.9, 0.85, 0.8, 0.75, 0.7, 0.65, 0.6, 0.55, 0.5};
|
||||
Mat X = linspace(0,1,11);
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
Mat(11,1, CV_32FC1, r).clone(), // red
|
||||
Mat(11,1, CV_32FC1, g).clone(), // green
|
||||
Mat(11,1, CV_32FC1, b).clone(), // blue
|
||||
n); // number of sample points
|
||||
}
|
||||
};
|
||||
|
||||
// Equals the GNU Octave colormap "rainbow".
|
||||
class Rainbow : public ColorMap {
|
||||
public:
|
||||
Rainbow() : ColorMap() {
|
||||
init(256);
|
||||
}
|
||||
|
||||
Rainbow(int n) : ColorMap() {
|
||||
init(n);
|
||||
}
|
||||
|
||||
void init(int n) {
|
||||
float r[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9365079365079367, 0.8571428571428572, 0.7777777777777777, 0.6984126984126986, 0.6190476190476191, 0.53968253968254, 0.4603174603174605, 0.3809523809523814, 0.3015873015873018, 0.2222222222222223, 0.1428571428571432, 0.06349206349206415, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.03174603174603208, 0.08465608465608465, 0.1375661375661377, 0.1904761904761907, 0.2433862433862437, 0.2962962962962963, 0.3492063492063493, 0.4021164021164023, 0.4550264550264553, 0.5079365079365079, 0.5608465608465609, 0.6137566137566139, 0.666666666666667};
|
||||
float g[] = { 0, 0.03968253968253968, 0.07936507936507936, 0.119047619047619, 0.1587301587301587, 0.1984126984126984, 0.2380952380952381, 0.2777777777777778, 0.3174603174603174, 0.3571428571428571, 0.3968253968253968, 0.4365079365079365, 0.4761904761904762, 0.5158730158730158, 0.5555555555555556, 0.5952380952380952, 0.6349206349206349, 0.6746031746031745, 0.7142857142857142, 0.753968253968254, 0.7936507936507936, 0.8333333333333333, 0.873015873015873, 0.9126984126984127, 0.9523809523809523, 0.992063492063492, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9841269841269842, 0.9047619047619047, 0.8253968253968256, 0.7460317460317465, 0.666666666666667, 0.587301587301587, 0.5079365079365079, 0.4285714285714288, 0.3492063492063493, 0.2698412698412698, 0.1904761904761907, 0.1111111111111116, 0.03174603174603208, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
float b[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.01587301587301582, 0.09523809523809534, 0.1746031746031744, 0.2539682539682535, 0.333333333333333, 0.412698412698413, 0.4920634920634921, 0.5714285714285712, 0.6507936507936507, 0.7301587301587302, 0.8095238095238093, 0.8888888888888884, 0.9682539682539679, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
Mat X = linspace(0,1,64);
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
Mat(64,1, CV_32FC1, r).clone(), // red
|
||||
Mat(64,1, CV_32FC1, g).clone(), // green
|
||||
Mat(64,1, CV_32FC1, b).clone(), // blue
|
||||
n); // number of sample points
|
||||
}
|
||||
};
|
||||
|
||||
// Equals the GNU Octave colormap "ocean".
|
||||
class Ocean : public ColorMap {
|
||||
public:
|
||||
Ocean() : ColorMap() {
|
||||
init(256);
|
||||
}
|
||||
|
||||
Ocean(int n) : ColorMap() {
|
||||
init(n);
|
||||
}
|
||||
|
||||
void init(int n) {
|
||||
float r[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.04761904761904762, 0.09523809523809523, 0.1428571428571428, 0.1904761904761905, 0.2380952380952381, 0.2857142857142857, 0.3333333333333333, 0.3809523809523809, 0.4285714285714285, 0.4761904761904762, 0.5238095238095238, 0.5714285714285714, 0.6190476190476191, 0.6666666666666666, 0.7142857142857143, 0.7619047619047619, 0.8095238095238095, 0.8571428571428571, 0.9047619047619048, 0.9523809523809523, 1};
|
||||
float g[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.02380952380952381, 0.04761904761904762, 0.07142857142857142, 0.09523809523809523, 0.119047619047619, 0.1428571428571428, 0.1666666666666667, 0.1904761904761905, 0.2142857142857143, 0.2380952380952381, 0.2619047619047619, 0.2857142857142857, 0.3095238095238095, 0.3333333333333333, 0.3571428571428572, 0.3809523809523809, 0.4047619047619048, 0.4285714285714285, 0.4523809523809524, 0.4761904761904762, 0.5, 0.5238095238095238, 0.5476190476190477, 0.5714285714285714, 0.5952380952380952, 0.6190476190476191, 0.6428571428571429, 0.6666666666666666, 0.6904761904761905, 0.7142857142857143, 0.7380952380952381, 0.7619047619047619, 0.7857142857142857, 0.8095238095238095, 0.8333333333333334, 0.8571428571428571, 0.8809523809523809, 0.9047619047619048, 0.9285714285714286, 0.9523809523809523, 0.9761904761904762, 1};
|
||||
float b[] = { 0, 0.01587301587301587, 0.03174603174603174, 0.04761904761904762, 0.06349206349206349, 0.07936507936507936, 0.09523809523809523, 0.1111111111111111, 0.126984126984127, 0.1428571428571428, 0.1587301587301587, 0.1746031746031746, 0.1904761904761905, 0.2063492063492063, 0.2222222222222222, 0.2380952380952381, 0.253968253968254, 0.2698412698412698, 0.2857142857142857, 0.3015873015873016, 0.3174603174603174, 0.3333333333333333, 0.3492063492063492, 0.3650793650793651, 0.3809523809523809, 0.3968253968253968, 0.4126984126984127, 0.4285714285714285, 0.4444444444444444, 0.4603174603174603, 0.4761904761904762, 0.492063492063492, 0.5079365079365079, 0.5238095238095238, 0.5396825396825397, 0.5555555555555556, 0.5714285714285714, 0.5873015873015873, 0.6031746031746031, 0.6190476190476191, 0.6349206349206349, 0.6507936507936508, 0.6666666666666666, 0.6825396825396826, 0.6984126984126984, 0.7142857142857143, 0.7301587301587301, 0.746031746031746, 0.7619047619047619, 0.7777777777777778, 0.7936507936507936, 0.8095238095238095, 0.8253968253968254, 0.8412698412698413, 0.8571428571428571, 0.873015873015873, 0.8888888888888888, 0.9047619047619048, 0.9206349206349206, 0.9365079365079365, 0.9523809523809523, 0.9682539682539683, 0.9841269841269841, 1};
|
||||
Mat X = linspace(0,1,64);
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
Mat(64,1, CV_32FC1, r).clone(), // red
|
||||
Mat(64,1, CV_32FC1, g).clone(), // green
|
||||
Mat(64,1, CV_32FC1, b).clone(), // blue
|
||||
n); // number of sample points
|
||||
}
|
||||
};
|
||||
|
||||
// Equals the GNU Octave colormap "summer".
|
||||
class Summer : public ColorMap {
|
||||
public:
|
||||
Summer() : ColorMap() {
|
||||
init(256);
|
||||
}
|
||||
|
||||
Summer(int n) : ColorMap() {
|
||||
init(n);
|
||||
}
|
||||
|
||||
void init(int n) {
|
||||
float r[] = { 0, 0.01587301587301587, 0.03174603174603174, 0.04761904761904762, 0.06349206349206349, 0.07936507936507936, 0.09523809523809523, 0.1111111111111111, 0.126984126984127, 0.1428571428571428, 0.1587301587301587, 0.1746031746031746, 0.1904761904761905, 0.2063492063492063, 0.2222222222222222, 0.2380952380952381, 0.253968253968254, 0.2698412698412698, 0.2857142857142857, 0.3015873015873016, 0.3174603174603174, 0.3333333333333333, 0.3492063492063492, 0.3650793650793651, 0.3809523809523809, 0.3968253968253968, 0.4126984126984127, 0.4285714285714285, 0.4444444444444444, 0.4603174603174603, 0.4761904761904762, 0.492063492063492, 0.5079365079365079, 0.5238095238095238, 0.5396825396825397, 0.5555555555555556, 0.5714285714285714, 0.5873015873015873, 0.6031746031746031, 0.6190476190476191, 0.6349206349206349, 0.6507936507936508, 0.6666666666666666, 0.6825396825396826, 0.6984126984126984, 0.7142857142857143, 0.7301587301587301, 0.746031746031746, 0.7619047619047619, 0.7777777777777778, 0.7936507936507936, 0.8095238095238095, 0.8253968253968254, 0.8412698412698413, 0.8571428571428571, 0.873015873015873, 0.8888888888888888, 0.9047619047619048, 0.9206349206349206, 0.9365079365079365, 0.9523809523809523, 0.9682539682539683, 0.9841269841269841, 1};
|
||||
float g[] = { 0.5, 0.5079365079365079, 0.5158730158730158, 0.5238095238095238, 0.5317460317460317, 0.5396825396825397, 0.5476190476190477, 0.5555555555555556, 0.5634920634920635, 0.5714285714285714, 0.5793650793650793, 0.5873015873015873, 0.5952380952380952, 0.6031746031746031, 0.6111111111111112, 0.6190476190476191, 0.626984126984127, 0.6349206349206349, 0.6428571428571428, 0.6507936507936508, 0.6587301587301587, 0.6666666666666666, 0.6746031746031746, 0.6825396825396826, 0.6904761904761905, 0.6984126984126984, 0.7063492063492063, 0.7142857142857143, 0.7222222222222222, 0.7301587301587301, 0.7380952380952381, 0.746031746031746, 0.753968253968254, 0.7619047619047619, 0.7698412698412698, 0.7777777777777778, 0.7857142857142857, 0.7936507936507937, 0.8015873015873016, 0.8095238095238095, 0.8174603174603174, 0.8253968253968254, 0.8333333333333333, 0.8412698412698413, 0.8492063492063492, 0.8571428571428572, 0.8650793650793651, 0.873015873015873, 0.8809523809523809, 0.8888888888888888, 0.8968253968253967, 0.9047619047619048, 0.9126984126984127, 0.9206349206349207, 0.9285714285714286, 0.9365079365079365, 0.9444444444444444, 0.9523809523809523, 0.9603174603174602, 0.9682539682539683, 0.9761904761904762, 0.9841269841269842, 0.9920634920634921, 1};
|
||||
float b[] = { 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4};
|
||||
Mat X = linspace(0,1,64);
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
Mat(64,1, CV_32FC1, r).clone(), // red
|
||||
Mat(64,1, CV_32FC1, g).clone(), // green
|
||||
Mat(64,1, CV_32FC1, b).clone(), // blue
|
||||
n); // number of sample points
|
||||
}
|
||||
};
|
||||
|
||||
// Equals the GNU Octave colormap "spring".
|
||||
class Spring : public ColorMap {
|
||||
public:
|
||||
Spring() : ColorMap() {
|
||||
init(256);
|
||||
}
|
||||
|
||||
Spring(int n) : ColorMap() {
|
||||
init(n);
|
||||
}
|
||||
|
||||
void init(int n) {
|
||||
float r[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
float g[] = { 0, 0.01587301587301587, 0.03174603174603174, 0.04761904761904762, 0.06349206349206349, 0.07936507936507936, 0.09523809523809523, 0.1111111111111111, 0.126984126984127, 0.1428571428571428, 0.1587301587301587, 0.1746031746031746, 0.1904761904761905, 0.2063492063492063, 0.2222222222222222, 0.2380952380952381, 0.253968253968254, 0.2698412698412698, 0.2857142857142857, 0.3015873015873016, 0.3174603174603174, 0.3333333333333333, 0.3492063492063492, 0.3650793650793651, 0.3809523809523809, 0.3968253968253968, 0.4126984126984127, 0.4285714285714285, 0.4444444444444444, 0.4603174603174603, 0.4761904761904762, 0.492063492063492, 0.5079365079365079, 0.5238095238095238, 0.5396825396825397, 0.5555555555555556, 0.5714285714285714, 0.5873015873015873, 0.6031746031746031, 0.6190476190476191, 0.6349206349206349, 0.6507936507936508, 0.6666666666666666, 0.6825396825396826, 0.6984126984126984, 0.7142857142857143, 0.7301587301587301, 0.746031746031746, 0.7619047619047619, 0.7777777777777778, 0.7936507936507936, 0.8095238095238095, 0.8253968253968254, 0.8412698412698413, 0.8571428571428571, 0.873015873015873, 0.8888888888888888, 0.9047619047619048, 0.9206349206349206, 0.9365079365079365, 0.9523809523809523, 0.9682539682539683, 0.9841269841269841, 1};
|
||||
float b[] = { 1, 0.9841269841269842, 0.9682539682539683, 0.9523809523809523, 0.9365079365079365, 0.9206349206349207, 0.9047619047619048, 0.8888888888888888, 0.873015873015873, 0.8571428571428572, 0.8412698412698413, 0.8253968253968254, 0.8095238095238095, 0.7936507936507937, 0.7777777777777778, 0.7619047619047619, 0.746031746031746, 0.7301587301587302, 0.7142857142857143, 0.6984126984126984, 0.6825396825396826, 0.6666666666666667, 0.6507936507936508, 0.6349206349206349, 0.6190476190476191, 0.6031746031746033, 0.5873015873015873, 0.5714285714285714, 0.5555555555555556, 0.5396825396825398, 0.5238095238095238, 0.5079365079365079, 0.4920634920634921, 0.4761904761904762, 0.4603174603174603, 0.4444444444444444, 0.4285714285714286, 0.4126984126984127, 0.3968253968253969, 0.3809523809523809, 0.3650793650793651, 0.3492063492063492, 0.3333333333333334, 0.3174603174603174, 0.3015873015873016, 0.2857142857142857, 0.2698412698412699, 0.253968253968254, 0.2380952380952381, 0.2222222222222222, 0.2063492063492064, 0.1904761904761905, 0.1746031746031746, 0.1587301587301587, 0.1428571428571429, 0.126984126984127, 0.1111111111111112, 0.09523809523809523, 0.07936507936507942, 0.06349206349206349, 0.04761904761904767, 0.03174603174603174, 0.01587301587301593, 0};
|
||||
Mat X = linspace(0,1,64);
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
Mat(64,1, CV_32FC1, r).clone(), // red
|
||||
Mat(64,1, CV_32FC1, g).clone(), // green
|
||||
Mat(64,1, CV_32FC1, b).clone(), // blue
|
||||
n); // number of sample points
|
||||
}
|
||||
};
|
||||
|
||||
// Equals the GNU Octave colormap "cool".
|
||||
class Cool : public ColorMap {
|
||||
public:
|
||||
Cool() : ColorMap() {
|
||||
init(256);
|
||||
}
|
||||
|
||||
Cool(int n) : ColorMap() {
|
||||
init(n);
|
||||
}
|
||||
|
||||
void init(int n) {
|
||||
float r[] = { 0, 0.01587301587301587, 0.03174603174603174, 0.04761904761904762, 0.06349206349206349, 0.07936507936507936, 0.09523809523809523, 0.1111111111111111, 0.126984126984127, 0.1428571428571428, 0.1587301587301587, 0.1746031746031746, 0.1904761904761905, 0.2063492063492063, 0.2222222222222222, 0.2380952380952381, 0.253968253968254, 0.2698412698412698, 0.2857142857142857, 0.3015873015873016, 0.3174603174603174, 0.3333333333333333, 0.3492063492063492, 0.3650793650793651, 0.3809523809523809, 0.3968253968253968, 0.4126984126984127, 0.4285714285714285, 0.4444444444444444, 0.4603174603174603, 0.4761904761904762, 0.492063492063492, 0.5079365079365079, 0.5238095238095238, 0.5396825396825397, 0.5555555555555556, 0.5714285714285714, 0.5873015873015873, 0.6031746031746031, 0.6190476190476191, 0.6349206349206349, 0.6507936507936508, 0.6666666666666666, 0.6825396825396826, 0.6984126984126984, 0.7142857142857143, 0.7301587301587301, 0.746031746031746, 0.7619047619047619, 0.7777777777777778, 0.7936507936507936, 0.8095238095238095, 0.8253968253968254, 0.8412698412698413, 0.8571428571428571, 0.873015873015873, 0.8888888888888888, 0.9047619047619048, 0.9206349206349206, 0.9365079365079365, 0.9523809523809523, 0.9682539682539683, 0.9841269841269841, 1};
|
||||
float g[] = { 1, 0.9841269841269842, 0.9682539682539683, 0.9523809523809523, 0.9365079365079365, 0.9206349206349207, 0.9047619047619048, 0.8888888888888888, 0.873015873015873, 0.8571428571428572, 0.8412698412698413, 0.8253968253968254, 0.8095238095238095, 0.7936507936507937, 0.7777777777777778, 0.7619047619047619, 0.746031746031746, 0.7301587301587302, 0.7142857142857143, 0.6984126984126984, 0.6825396825396826, 0.6666666666666667, 0.6507936507936508, 0.6349206349206349, 0.6190476190476191, 0.6031746031746033, 0.5873015873015873, 0.5714285714285714, 0.5555555555555556, 0.5396825396825398, 0.5238095238095238, 0.5079365079365079, 0.4920634920634921, 0.4761904761904762, 0.4603174603174603, 0.4444444444444444, 0.4285714285714286, 0.4126984126984127, 0.3968253968253969, 0.3809523809523809, 0.3650793650793651, 0.3492063492063492, 0.3333333333333334, 0.3174603174603174, 0.3015873015873016, 0.2857142857142857, 0.2698412698412699, 0.253968253968254, 0.2380952380952381, 0.2222222222222222, 0.2063492063492064, 0.1904761904761905, 0.1746031746031746, 0.1587301587301587, 0.1428571428571429, 0.126984126984127, 0.1111111111111112, 0.09523809523809523, 0.07936507936507942, 0.06349206349206349, 0.04761904761904767, 0.03174603174603174, 0.01587301587301593, 0};
|
||||
float b[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
Mat X = linspace(0,1,64);
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
Mat(64,1, CV_32FC1, r).clone(), // red
|
||||
Mat(64,1, CV_32FC1, g).clone(), // green
|
||||
Mat(64,1, CV_32FC1, b).clone(), // blue
|
||||
n); // number of sample points
|
||||
}
|
||||
};
|
||||
|
||||
// Equals the GNU Octave colormap "hsv".
|
||||
class HSV : public ColorMap {
|
||||
public:
|
||||
HSV() : ColorMap() {
|
||||
init(256);
|
||||
}
|
||||
|
||||
HSV(int n) : ColorMap() {
|
||||
init(n);
|
||||
}
|
||||
|
||||
void init(int n) {
|
||||
float r[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9523809523809526, 0.8571428571428568, 0.7619047619047614, 0.6666666666666665, 0.5714285714285716, 0.4761904761904763, 0.3809523809523805, 0.2857142857142856, 0.1904761904761907, 0.0952380952380949, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.09523809523809557, 0.1904761904761905, 0.2857142857142854, 0.3809523809523809, 0.4761904761904765, 0.5714285714285714, 0.6666666666666663, 0.7619047619047619, 0.8571428571428574, 0.9523809523809523, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
float g[] = { 0, 0.09523809523809523, 0.1904761904761905, 0.2857142857142857, 0.3809523809523809, 0.4761904761904762, 0.5714285714285714, 0.6666666666666666, 0.7619047619047619, 0.8571428571428571, 0.9523809523809523, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9523809523809526, 0.8571428571428577, 0.7619047619047619, 0.6666666666666665, 0.5714285714285716, 0.4761904761904767, 0.3809523809523814, 0.2857142857142856, 0.1904761904761907, 0.09523809523809579, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
float b[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.09523809523809523, 0.1904761904761905, 0.2857142857142857, 0.3809523809523809, 0.4761904761904762, 0.5714285714285714, 0.6666666666666666, 0.7619047619047619, 0.8571428571428571, 0.9523809523809523, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9523809523809526, 0.8571428571428577, 0.7619047619047614, 0.6666666666666665, 0.5714285714285716, 0.4761904761904767, 0.3809523809523805, 0.2857142857142856, 0.1904761904761907, 0.09523809523809579, 0};
|
||||
Mat X = linspace(0,1,64);
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
Mat(64,1, CV_32FC1, r).clone(), // red
|
||||
Mat(64,1, CV_32FC1, g).clone(), // green
|
||||
Mat(64,1, CV_32FC1, b).clone(), // blue
|
||||
n); // number of sample points
|
||||
}
|
||||
};
|
||||
|
||||
// Equals the GNU Octave colormap "pink".
|
||||
class Pink : public ColorMap {
|
||||
public:
|
||||
Pink() : ColorMap() {
|
||||
init(256);
|
||||
}
|
||||
|
||||
Pink(int n) : ColorMap() {
|
||||
init(n);
|
||||
}
|
||||
|
||||
void init(int n) {
|
||||
float r[] = { 0, 0.1571348402636772, 0.2222222222222222, 0.2721655269759087, 0.3142696805273544, 0.3513641844631533, 0.3849001794597505, 0.415739709641549, 0.4444444444444444, 0.4714045207910317, 0.4969039949999532, 0.5211573066470477, 0.5443310539518174, 0.5665577237325317, 0.5879447357921312, 0.6085806194501846, 0.6285393610547089, 0.6478835438717, 0.6666666666666666, 0.6849348892187751, 0.7027283689263065, 0.7200822998230956, 0.7370277311900888, 0.753592220347252, 0.7663560447348133, 0.7732293307186413, 0.7800420555749596, 0.7867957924694432, 0.7934920476158722, 0.8001322641986387, 0.8067178260046388, 0.8132500607904444, 0.8197302434079591, 0.8261595987094034, 0.8325393042503717, 0.8388704928078611, 0.8451542547285166, 0.8513916401208816, 0.8575836609041332, 0.8637312927246217, 0.8698354767504924, 0.8758971213537393, 0.8819171036881968, 0.8878962711712378, 0.8938354428762595, 0.8997354108424372, 0.9055969413076769, 0.9114207758701963, 0.9172076325837248, 0.9229582069908971, 0.9286731730990523, 0.9343531843023135, 0.9399988742535192, 0.9456108576893002, 0.9511897312113418, 0.9567360740266436, 0.9622504486493763, 0.9677334015667416, 0.9731854638710686, 0.9786071518602129, 0.9839989676081821, 0.9893613995077727, 0.9946949227868761, 1};
|
||||
float g[] = { 0, 0.1028688999747279, 0.1454785934906616, 0.1781741612749496, 0.2057377999494559, 0.2300218531141181, 0.2519763153394848, 0.2721655269759087, 0.2909571869813232, 0.3086066999241838, 0.3253000243161777, 0.3411775438127727, 0.3563483225498992, 0.3708990935094579, 0.3849001794597505, 0.3984095364447979, 0.4114755998989117, 0.4241393401869012, 0.4364357804719847, 0.4483951394230328, 0.4600437062282361, 0.4714045207910317, 0.4824979096371639, 0.4933419132673033, 0.5091750772173156, 0.5328701692569688, 0.5555555555555556, 0.5773502691896257, 0.5983516452371671, 0.6186404847588913, 0.6382847385042254, 0.6573421981221795, 0.6758625033664688, 0.6938886664887108, 0.7114582486036499, 0.7286042804780002, 0.7453559924999299, 0.7617394000445604, 0.7777777777777778, 0.7934920476158723, 0.8089010988089465, 0.8240220541217402, 0.8388704928078611, 0.8534606386520677, 0.8678055195451838, 0.8819171036881968, 0.8958064164776166, 0.9094836413191612, 0.9172076325837248, 0.9229582069908971, 0.9286731730990523, 0.9343531843023135, 0.9399988742535192, 0.9456108576893002, 0.9511897312113418, 0.9567360740266436, 0.9622504486493763, 0.9677334015667416, 0.9731854638710686, 0.9786071518602129, 0.9839989676081821, 0.9893613995077727, 0.9946949227868761, 1};
|
||||
float b[] = { 0, 0.1028688999747279, 0.1454785934906616, 0.1781741612749496, 0.2057377999494559, 0.2300218531141181, 0.2519763153394848, 0.2721655269759087, 0.2909571869813232, 0.3086066999241838, 0.3253000243161777, 0.3411775438127727, 0.3563483225498992, 0.3708990935094579, 0.3849001794597505, 0.3984095364447979, 0.4114755998989117, 0.4241393401869012, 0.4364357804719847, 0.4483951394230328, 0.4600437062282361, 0.4714045207910317, 0.4824979096371639, 0.4933419132673033, 0.5039526306789697, 0.5143444998736397, 0.5245305283129621, 0.5345224838248488, 0.5443310539518174, 0.5539659798925444, 0.563436169819011, 0.5727497953228163, 0.5819143739626463, 0.5909368402852788, 0.5998236072282915, 0.6085806194501846, 0.6172133998483676, 0.6257270902992705, 0.6341264874742278, 0.642416074439621, 0.6506000486323554, 0.6586823467062358, 0.6666666666666666, 0.6745564876468501, 0.6823550876255453, 0.6900655593423541, 0.6976908246297114, 0.7052336473499384, 0.7237468644557459, 0.7453559924999298, 0.7663560447348133, 0.7867957924694432, 0.8067178260046388, 0.8261595987094034, 0.8451542547285166, 0.8637312927246217, 0.8819171036881968, 0.8997354108424372, 0.9172076325837248, 0.9343531843023135, 0.9511897312113418, 0.9677334015667416, 0.9839989676081821, 1};
|
||||
Mat X = linspace(0,1,64);
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
Mat(64,1, CV_32FC1, r).clone(), // red
|
||||
Mat(64,1, CV_32FC1, g).clone(), // green
|
||||
Mat(64,1, CV_32FC1, b).clone(), // blue
|
||||
n); // number of sample points
|
||||
}
|
||||
};
|
||||
|
||||
// Equals the GNU Octave colormap "hot".
|
||||
class Hot : public ColorMap {
|
||||
public:
|
||||
Hot() : ColorMap() {
|
||||
init(256);
|
||||
}
|
||||
|
||||
Hot(int n) : ColorMap() {
|
||||
init(n);
|
||||
}
|
||||
|
||||
void init(int n) {
|
||||
float r[] = { 0, 0.03968253968253968, 0.07936507936507936, 0.119047619047619, 0.1587301587301587, 0.1984126984126984, 0.2380952380952381, 0.2777777777777778, 0.3174603174603174, 0.3571428571428571, 0.3968253968253968, 0.4365079365079365, 0.4761904761904762, 0.5158730158730158, 0.5555555555555556, 0.5952380952380952, 0.6349206349206349, 0.6746031746031745, 0.7142857142857142, 0.753968253968254, 0.7936507936507936, 0.8333333333333333, 0.873015873015873, 0.9126984126984127, 0.9523809523809523, 0.992063492063492, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
float g[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.03174603174603163, 0.0714285714285714, 0.1111111111111112, 0.1507936507936507, 0.1904761904761905, 0.23015873015873, 0.2698412698412698, 0.3095238095238093, 0.3492063492063491, 0.3888888888888888, 0.4285714285714284, 0.4682539682539679, 0.5079365079365079, 0.5476190476190477, 0.5873015873015872, 0.6269841269841268, 0.6666666666666665, 0.7063492063492065, 0.746031746031746, 0.7857142857142856, 0.8253968253968254, 0.8650793650793651, 0.9047619047619047, 0.9444444444444442, 0.984126984126984, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
float b[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.04761904761904745, 0.1269841269841265, 0.2063492063492056, 0.2857142857142856, 0.3650793650793656, 0.4444444444444446, 0.5238095238095237, 0.6031746031746028, 0.6825396825396828, 0.7619047619047619, 0.8412698412698409, 0.92063492063492, 1};
|
||||
Mat X = linspace(0,1,64);
|
||||
this->_lut = ColorMap::linear_colormap(X,
|
||||
Mat(64,1, CV_32FC1, r).clone(), // red
|
||||
Mat(64,1, CV_32FC1, g).clone(), // green
|
||||
Mat(64,1, CV_32FC1, b).clone(), // blue
|
||||
n); // number of sample points
|
||||
}
|
||||
};
|
||||
|
||||
void ColorMap::operator()(InputArray _src, OutputArray _dst) const
|
||||
{
|
||||
if(_lut.total() != 256)
|
||||
CV_Error(Error::StsAssert, "cv::LUT only supports tables of size 256.");
|
||||
Mat src = _src.getMat();
|
||||
// Return original matrix if wrong type is given (is fail loud better here?)
|
||||
if(src.type() != CV_8UC1 && src.type() != CV_8UC3)
|
||||
{
|
||||
src.copyTo(_dst);
|
||||
return;
|
||||
}
|
||||
// Turn into a BGR matrix into its grayscale representation.
|
||||
if(src.type() == CV_8UC3)
|
||||
cvtColor(src.clone(), src, COLOR_BGR2GRAY);
|
||||
cvtColor(src.clone(), src, COLOR_GRAY2BGR);
|
||||
// Apply the ColorMap.
|
||||
LUT(src, _lut, _dst);
|
||||
}
|
||||
|
||||
Mat ColorMap::linear_colormap(InputArray X,
|
||||
InputArray r, InputArray g, InputArray b,
|
||||
InputArray xi) {
|
||||
Mat lut, lut8;
|
||||
Mat planes[] = {
|
||||
interp1(X, b, xi),
|
||||
interp1(X, g, xi),
|
||||
interp1(X, r, xi)};
|
||||
merge(planes, 3, lut);
|
||||
lut.convertTo(lut8, CV_8U, 255.);
|
||||
return lut8;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void applyColorMap(InputArray src, OutputArray dst, int colormap)
|
||||
{
|
||||
colormap::ColorMap* cm =
|
||||
colormap == COLORMAP_AUTUMN ? (colormap::ColorMap*)(new colormap::Autumn) :
|
||||
colormap == COLORMAP_BONE ? (colormap::ColorMap*)(new colormap::Bone) :
|
||||
colormap == COLORMAP_COOL ? (colormap::ColorMap*)(new colormap::Cool) :
|
||||
colormap == COLORMAP_HOT ? (colormap::ColorMap*)(new colormap::Hot) :
|
||||
colormap == COLORMAP_HSV ? (colormap::ColorMap*)(new colormap::HSV) :
|
||||
colormap == COLORMAP_JET ? (colormap::ColorMap*)(new colormap::Jet) :
|
||||
colormap == COLORMAP_OCEAN ? (colormap::ColorMap*)(new colormap::Ocean) :
|
||||
colormap == COLORMAP_PINK ? (colormap::ColorMap*)(new colormap::Pink) :
|
||||
colormap == COLORMAP_RAINBOW ? (colormap::ColorMap*)(new colormap::Rainbow) :
|
||||
colormap == COLORMAP_SPRING ? (colormap::ColorMap*)(new colormap::Spring) :
|
||||
colormap == COLORMAP_SUMMER ? (colormap::ColorMap*)(new colormap::Summer) :
|
||||
colormap == COLORMAP_WINTER ? (colormap::ColorMap*)(new colormap::Winter) : 0;
|
||||
|
||||
if( !cm )
|
||||
CV_Error( Error::StsBadArg, "Unknown colormap id; use one of COLORMAP_*");
|
||||
|
||||
(*cm)(src, dst);
|
||||
|
||||
delete cm;
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencl_kernels.hpp"
|
||||
#include "opencl_kernels_imgproc.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencl_kernels.hpp"
|
||||
#include "opencl_kernels_imgproc.hpp"
|
||||
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
static IppStatus sts = ippInit();
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencl_kernels.hpp"
|
||||
#include "opencl_kernels_imgproc.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
#include <vector>
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencl_kernels.hpp"
|
||||
#include "opencl_kernels_imgproc.hpp"
|
||||
|
||||
/****************************************************************************************\
|
||||
Base Image Filter
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencl_kernels.hpp"
|
||||
#include "opencl_kernels_imgproc.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
// */
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencl_kernels.hpp"
|
||||
#include "opencl_kernels_imgproc.hpp"
|
||||
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
static IppStatus sts = ippInit();
|
||||
@@ -2074,7 +2074,8 @@ static bool ocl_resize( InputArray _src, OutputArray _dst, Size dsize,
|
||||
// datatypes because the observed error is low.
|
||||
bool useSampler = (interpolation == INTER_LINEAR && ocl::Device::getDefault().imageSupport() &&
|
||||
ocl::Image2D::canCreateAlias(src) && depth <= 4 &&
|
||||
ocl::Image2D::isFormatSupported(depth, cn, true));
|
||||
ocl::Image2D::isFormatSupported(depth, cn, true) &&
|
||||
src.offset==0);
|
||||
if (useSampler)
|
||||
{
|
||||
int wdepth = std::max(depth, CV_32S);
|
||||
@@ -2380,7 +2381,7 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
|
||||
inv_scale_y = (double)dsize.height/ssize.height;
|
||||
}
|
||||
|
||||
CV_OCL_RUN(_src.dims() <= 2 && _dst.isUMat(),
|
||||
CV_OCL_RUN(_src.dims() <= 2 && _dst.isUMat() && _src.cols() > 10 && _src.rows() > 10,
|
||||
ocl_resize(_src, _dst, dsize, inv_scale_x, inv_scale_y, interpolation))
|
||||
|
||||
Mat src = _src.getMat();
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
//
|
||||
//M*/
|
||||
#include "precomp.hpp"
|
||||
#include "opencl_kernels.hpp"
|
||||
#include "opencl_kernels_imgproc.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include <limits.h>
|
||||
#include "opencl_kernels.hpp"
|
||||
#include "opencl_kernels_imgproc.hpp"
|
||||
|
||||
/****************************************************************************************\
|
||||
Basic Morphological Operations: Erosion & Dilation
|
||||
@@ -1221,7 +1221,7 @@ static bool IPPMorphReplicate(int op, const Mat &src, Mat &dst, const Mat &kerne
|
||||
IPP_MORPH_CASE(CV_32FC3, 32f_C3R, 32f);
|
||||
IPP_MORPH_CASE(CV_32FC4, 32f_C4R, 32f);
|
||||
default:
|
||||
return false;
|
||||
;
|
||||
}
|
||||
|
||||
#undef IPP_MORPH_CASE
|
||||
@@ -1253,14 +1253,11 @@ static bool IPPMorphReplicate(int op, const Mat &src, Mat &dst, const Mat &kerne
|
||||
IPP_MORPH_CASE(CV_32FC3, 32f_C3R, 32f);
|
||||
IPP_MORPH_CASE(CV_32FC4, 32f_C4R, 32f);
|
||||
default:
|
||||
return false;
|
||||
;
|
||||
}
|
||||
#undef IPP_MORPH_CASE
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ >= 8
|
||||
return false; /// It disables false positive warning in GCC 4.8 and further
|
||||
#endif
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool IPPMorphOp(int op, InputArray _src, OutputArray _dst,
|
||||
@@ -1339,22 +1336,190 @@ static bool IPPMorphOp(int op, InputArray _src, OutputArray _dst,
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
#define ROUNDUP(sz, n) ((sz) + (n) - 1 - (((sz) + (n) - 1) % (n)))
|
||||
|
||||
static bool ocl_morphSmall( InputArray _src, OutputArray _dst, InputArray _kernel, Point anchor, int borderType,
|
||||
int op, int actual_op = -1, InputArray _extraMat = noArray())
|
||||
{
|
||||
const ocl::Device & dev = ocl::Device::getDefault();
|
||||
int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type), esz = CV_ELEM_SIZE(type);
|
||||
bool doubleSupport = dev.doubleFPConfig() > 0;
|
||||
|
||||
if (cn > 4 || (!doubleSupport && depth == CV_64F) ||
|
||||
_src.offset() % esz != 0 || _src.step() % esz != 0)
|
||||
return false;
|
||||
|
||||
bool haveExtraMat = !_extraMat.empty();
|
||||
CV_Assert(actual_op <= 3 || haveExtraMat);
|
||||
|
||||
Size ksize = _kernel.size();
|
||||
if (anchor.x < 0)
|
||||
anchor.x = ksize.width / 2;
|
||||
if (anchor.y < 0)
|
||||
anchor.y = ksize.height / 2;
|
||||
|
||||
Size size = _src.size(), wholeSize;
|
||||
bool isolated = (borderType & BORDER_ISOLATED) != 0;
|
||||
borderType &= ~BORDER_ISOLATED;
|
||||
int wdepth = depth, wtype = type;
|
||||
if (depth == CV_8U)
|
||||
{
|
||||
wdepth = CV_32S;
|
||||
wtype = CV_MAKETYPE(wdepth, cn);
|
||||
}
|
||||
char cvt[2][40];
|
||||
|
||||
const char * const borderMap[] = { "BORDER_CONSTANT", "BORDER_REPLICATE",
|
||||
"BORDER_REFLECT", 0, "BORDER_REFLECT_101" };
|
||||
size_t globalsize[2] = { size.width, size.height };
|
||||
|
||||
UMat src = _src.getUMat();
|
||||
if (!isolated)
|
||||
{
|
||||
Point ofs;
|
||||
src.locateROI(wholeSize, ofs);
|
||||
}
|
||||
|
||||
int h = isolated ? size.height : wholeSize.height;
|
||||
int w = isolated ? size.width : wholeSize.width;
|
||||
if (w < ksize.width || h < ksize.height)
|
||||
return false;
|
||||
|
||||
// Figure out what vector size to use for loading the pixels.
|
||||
int pxLoadNumPixels = cn != 1 || size.width % 4 ? 1 : 4;
|
||||
int pxLoadVecSize = cn * pxLoadNumPixels;
|
||||
|
||||
// Figure out how many pixels per work item to compute in X and Y
|
||||
// directions. Too many and we run out of registers.
|
||||
int pxPerWorkItemX = 1, pxPerWorkItemY = 1;
|
||||
if (cn <= 2 && ksize.width <= 4 && ksize.height <= 4)
|
||||
{
|
||||
pxPerWorkItemX = size.width % 8 ? size.width % 4 ? size.width % 2 ? 1 : 2 : 4 : 8;
|
||||
pxPerWorkItemY = size.height % 2 ? 1 : 2;
|
||||
}
|
||||
else if (cn < 4 || (ksize.width <= 4 && ksize.height <= 4))
|
||||
{
|
||||
pxPerWorkItemX = size.width % 2 ? 1 : 2;
|
||||
pxPerWorkItemY = size.height % 2 ? 1 : 2;
|
||||
}
|
||||
globalsize[0] = size.width / pxPerWorkItemX;
|
||||
globalsize[1] = size.height / pxPerWorkItemY;
|
||||
|
||||
// Need some padding in the private array for pixels
|
||||
int privDataWidth = ROUNDUP(pxPerWorkItemX + ksize.width - 1, pxLoadNumPixels);
|
||||
|
||||
// Make the global size a nice round number so the runtime can pick
|
||||
// from reasonable choices for the workgroup size
|
||||
const int wgRound = 256;
|
||||
globalsize[0] = ROUNDUP(globalsize[0], wgRound);
|
||||
|
||||
if (actual_op < 0)
|
||||
actual_op = op;
|
||||
|
||||
// build processing
|
||||
String processing;
|
||||
Mat kernel8u;
|
||||
_kernel.getMat().convertTo(kernel8u, CV_8U);
|
||||
for (int y = 0; y < kernel8u.rows; ++y)
|
||||
for (int x = 0; x < kernel8u.cols; ++x)
|
||||
if (kernel8u.at<uchar>(y, x) != 0)
|
||||
processing += format("PROCESS(%d,%d)", y, x);
|
||||
|
||||
|
||||
static const char * const op2str[] = { "OP_ERODE", "OP_DILATE", NULL, NULL, "OP_GRADIENT", "OP_TOPHAT", "OP_BLACKHAT" };
|
||||
String opts = format("-D cn=%d "
|
||||
"-D ANCHOR_X=%d -D ANCHOR_Y=%d -D KERNEL_SIZE_X=%d -D KERNEL_SIZE_Y=%d "
|
||||
"-D PX_LOAD_VEC_SIZE=%d -D PX_LOAD_NUM_PX=%d -D DEPTH_%d "
|
||||
"-D PX_PER_WI_X=%d -D PX_PER_WI_Y=%d -D PRIV_DATA_WIDTH=%d -D %s -D %s "
|
||||
"-D PX_LOAD_X_ITERATIONS=%d -D PX_LOAD_Y_ITERATIONS=%d "
|
||||
"-D srcT=%s -D srcT1=%s -D dstT=srcT -D dstT1=srcT1 -D WT=%s -D WT1=%s "
|
||||
"-D convertToWT=%s -D convertToDstT=%s -D PROCESS_ELEM_=%s -D %s%s",
|
||||
cn, anchor.x, anchor.y, ksize.width, ksize.height,
|
||||
pxLoadVecSize, pxLoadNumPixels, depth,
|
||||
pxPerWorkItemX, pxPerWorkItemY, privDataWidth, borderMap[borderType],
|
||||
isolated ? "BORDER_ISOLATED" : "NO_BORDER_ISOLATED",
|
||||
privDataWidth / pxLoadNumPixels, pxPerWorkItemY + ksize.height - 1,
|
||||
ocl::typeToStr(type), ocl::typeToStr(depth),
|
||||
haveExtraMat ? ocl::typeToStr(wtype):"srcT",//to prevent overflow - WT
|
||||
haveExtraMat ? ocl::typeToStr(wdepth):"srcT1",//to prevent overflow - WT1
|
||||
haveExtraMat ? ocl::convertTypeStr(depth, wdepth, cn, cvt[0]) : "noconvert",//to prevent overflow - src to WT
|
||||
haveExtraMat ? ocl::convertTypeStr(wdepth, depth, cn, cvt[1]) : "noconvert",//to prevent overflow - WT to dst
|
||||
processing.c_str(), op2str[op],
|
||||
actual_op == op ? "" : cv::format(" -D %s", op2str[actual_op]).c_str());
|
||||
|
||||
ocl::Kernel kernel("filterSmall", cv::ocl::imgproc::filterSmall_oclsrc, opts);
|
||||
if (kernel.empty())
|
||||
return false;
|
||||
|
||||
_dst.create(size, type);
|
||||
UMat dst = _dst.getUMat();
|
||||
|
||||
UMat source;
|
||||
if(src.u != dst.u)
|
||||
source = src;
|
||||
else
|
||||
{
|
||||
Point ofs;
|
||||
int cols = src.cols, rows = src.rows;
|
||||
src.locateROI(wholeSize, ofs);
|
||||
src.adjustROI(ofs.y, wholeSize.height - rows - ofs.y, ofs.x, wholeSize.width - cols - ofs.x);
|
||||
src.copyTo(source);
|
||||
|
||||
src.adjustROI(-ofs.y, -wholeSize.height + rows + ofs.y, -ofs.x, -wholeSize.width + cols + ofs.x);
|
||||
source.adjustROI(-ofs.y, -wholeSize.height + rows + ofs.y, -ofs.x, -wholeSize.width + cols + ofs.x);
|
||||
source.locateROI(wholeSize, ofs);
|
||||
}
|
||||
|
||||
UMat extraMat = _extraMat.getUMat();
|
||||
|
||||
int idxArg = kernel.set(0, ocl::KernelArg::PtrReadOnly(source));
|
||||
idxArg = kernel.set(idxArg, (int)source.step);
|
||||
int srcOffsetX = (int)((source.offset % source.step) / source.elemSize());
|
||||
int srcOffsetY = (int)(source.offset / source.step);
|
||||
int srcEndX = isolated ? srcOffsetX + size.width : wholeSize.width;
|
||||
int srcEndY = isolated ? srcOffsetY + size.height : wholeSize.height;
|
||||
idxArg = kernel.set(idxArg, srcOffsetX);
|
||||
idxArg = kernel.set(idxArg, srcOffsetY);
|
||||
idxArg = kernel.set(idxArg, srcEndX);
|
||||
idxArg = kernel.set(idxArg, srcEndY);
|
||||
idxArg = kernel.set(idxArg, ocl::KernelArg::WriteOnly(dst));
|
||||
|
||||
if (haveExtraMat)
|
||||
{
|
||||
idxArg = kernel.set(idxArg, ocl::KernelArg::ReadOnlyNoSize(extraMat));
|
||||
}
|
||||
|
||||
return kernel.run(2, globalsize, NULL, false);
|
||||
|
||||
}
|
||||
|
||||
static bool ocl_morphOp(InputArray _src, OutputArray _dst, InputArray _kernel,
|
||||
Point anchor, int iterations, int op, int borderType,
|
||||
const Scalar &, int actual_op = -1, InputArray _extraMat = noArray())
|
||||
{
|
||||
const ocl::Device & dev = ocl::Device::getDefault();
|
||||
int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
|
||||
bool doubleSupport = dev.doubleFPConfig() > 0;
|
||||
int type = _src.type(), depth = CV_MAT_DEPTH(type),
|
||||
cn = CV_MAT_CN(type), esz = CV_ELEM_SIZE(type);
|
||||
Mat kernel = _kernel.getMat();
|
||||
Size ksize = kernel.data ? kernel.size() : Size(3, 3), ssize = _src.size();
|
||||
|
||||
bool doubleSupport = dev.doubleFPConfig() > 0;
|
||||
if ((depth == CV_64F && !doubleSupport) || borderType != BORDER_CONSTANT)
|
||||
return false;
|
||||
|
||||
Mat kernel = _kernel.getMat();
|
||||
bool haveExtraMat = !_extraMat.empty();
|
||||
Size ksize = kernel.data ? kernel.size() : Size(3, 3), ssize = _src.size();
|
||||
CV_Assert(actual_op <= 3 || haveExtraMat);
|
||||
|
||||
// try to use OpenCL kernel adopted for small morph kernel
|
||||
if (dev.isIntel() && !(dev.type() & ocl::Device::TYPE_CPU) &&
|
||||
((ksize.width < 5 && ksize.height < 5 && esz <= 4) ||
|
||||
(ksize.width == 5 && ksize.height == 5 && cn == 1)) &&
|
||||
(iterations == 1))
|
||||
{
|
||||
if (ocl_morphSmall(_src, _dst, _kernel, anchor, borderType, op, actual_op, _extraMat))
|
||||
return true;
|
||||
}
|
||||
|
||||
if (iterations == 0 || kernel.rows*kernel.cols == 1)
|
||||
{
|
||||
_src.copyTo(_dst);
|
||||
|
||||
@@ -441,18 +441,18 @@ __kernel void YCrCb2RGB(__global const uchar* src, int src_step, int src_offset,
|
||||
__global DATA_TYPE * dstptr = (__global DATA_TYPE*)(dst + dst_index);
|
||||
|
||||
DATA_TYPE_4 src_pix = vload4(0, srcptr);
|
||||
DATA_TYPE y = src_pix.x, cr = src_pix.y, cb = src_pix.z;
|
||||
DATA_TYPE yp = src_pix.x, cr = src_pix.y, cb = src_pix.z;
|
||||
|
||||
#ifdef DEPTH_5
|
||||
__constant float * coeff = c_YCrCb2RGBCoeffs_f;
|
||||
float r = fma(coeff[0], cr - HALF_MAX, y);
|
||||
float g = fma(coeff[1], cr - HALF_MAX, fma(coeff[2], cb - HALF_MAX, y));
|
||||
float b = fma(coeff[3], cb - HALF_MAX, y);
|
||||
float r = fma(coeff[0], cr - HALF_MAX, yp);
|
||||
float g = fma(coeff[1], cr - HALF_MAX, fma(coeff[2], cb - HALF_MAX, yp));
|
||||
float b = fma(coeff[3], cb - HALF_MAX, yp);
|
||||
#else
|
||||
__constant int * coeff = c_YCrCb2RGBCoeffs_i;
|
||||
int r = y + CV_DESCALE(coeff[0] * (cr - HALF_MAX), yuv_shift);
|
||||
int g = y + CV_DESCALE(mad24(coeff[1], cr - HALF_MAX, coeff[2] * (cb - HALF_MAX)), yuv_shift);
|
||||
int b = y + CV_DESCALE(coeff[3] * (cb - HALF_MAX), yuv_shift);
|
||||
int r = yp + CV_DESCALE(coeff[0] * (cr - HALF_MAX), yuv_shift);
|
||||
int g = yp + CV_DESCALE(mad24(coeff[1], cr - HALF_MAX, coeff[2] * (cb - HALF_MAX)), yuv_shift);
|
||||
int b = yp + CV_DESCALE(coeff[3] * (cb - HALF_MAX), yuv_shift);
|
||||
#endif
|
||||
|
||||
dstptr[(bidx^2)] = SAT_CAST(r);
|
||||
@@ -1796,6 +1796,10 @@ __kernel void Luv2BGR(__global const uchar * srcptr, int src_step, int src_offse
|
||||
float G = fma(X, coeffs[3], fma(Y, coeffs[4], Z * coeffs[5]));
|
||||
float B = fma(X, coeffs[6], fma(Y, coeffs[7], Z * coeffs[8]));
|
||||
|
||||
R = clamp(R, 0.f, 1.f);
|
||||
G = clamp(G, 0.f, 1.f);
|
||||
B = clamp(B, 0.f, 1.f);
|
||||
|
||||
#ifdef SRGB
|
||||
R = splineInterpolate(R*GammaTabScale, gammaTab, GAMMA_TAB_SIZE);
|
||||
G = splineInterpolate(G*GammaTabScale, gammaTab, GAMMA_TAB_SIZE);
|
||||
@@ -1853,6 +1857,10 @@ __kernel void Luv2BGR(__global const uchar * src, int src_step, int src_offset,
|
||||
float G = fma(X, coeffs[3], fma(Y, coeffs[4], Z * coeffs[5]));
|
||||
float B = fma(X, coeffs[6], fma(Y, coeffs[7], Z * coeffs[8]));
|
||||
|
||||
R = clamp(R, 0.f, 1.f);
|
||||
G = clamp(G, 0.f, 1.f);
|
||||
B = clamp(B, 0.f, 1.f);
|
||||
|
||||
#ifdef SRGB
|
||||
R = splineInterpolate(R*GammaTabScale, gammaTab, GAMMA_TAB_SIZE);
|
||||
G = splineInterpolate(G*GammaTabScale, gammaTab, GAMMA_TAB_SIZE);
|
||||
|
||||
@@ -153,35 +153,10 @@ inline bool isBorder(const struct RectCoords bounds, int2 coord, int numPixels)
|
||||
}
|
||||
#endif
|
||||
|
||||
inline WT getBorderPixel(const struct RectCoords bounds, int2 coord,
|
||||
__global const uchar * srcptr, int srcstep)
|
||||
{
|
||||
#ifdef BORDER_CONSTANT
|
||||
return (WT)(0);
|
||||
#else
|
||||
int selected_col = coord.x;
|
||||
int selected_row = coord.y;
|
||||
|
||||
EXTRAPOLATE(selected_col, selected_row,
|
||||
bounds.x1, bounds.y1,
|
||||
bounds.x2, bounds.y2);
|
||||
|
||||
__global const uchar* ptr = srcptr + mad24(selected_row, srcstep, selected_col * SRCSIZE);
|
||||
return convertToWT(loadpix(ptr));
|
||||
#endif
|
||||
}
|
||||
|
||||
inline WT readSrcPixelSingle(int2 pos, __global const uchar * srcptr,
|
||||
int srcstep, const struct RectCoords srcCoords)
|
||||
{
|
||||
if (!isBorder(srcCoords, pos, 1))
|
||||
{
|
||||
__global const uchar * ptr = srcptr + mad24(pos.y, srcstep, pos.x * SRCSIZE);
|
||||
return convertToWT(loadpix(ptr));
|
||||
}
|
||||
else
|
||||
return getBorderPixel(srcCoords, pos, srcptr, srcstep);
|
||||
}
|
||||
#define float1 float
|
||||
#define uchar1 uchar
|
||||
#define int1 int
|
||||
#define uint1 unit
|
||||
|
||||
#define __CAT(x, y) x##y
|
||||
#define CAT(x, y) __CAT(x, y)
|
||||
@@ -191,7 +166,7 @@ inline WT readSrcPixelSingle(int2 pos, __global const uchar * srcptr,
|
||||
#define PX_LOAD_FLOAT_VEC_TYPE CAT(WT1, PX_LOAD_VEC_SIZE)
|
||||
#define PX_LOAD_FLOAT_VEC_CONV CAT(convert_, PX_LOAD_FLOAT_VEC_TYPE)
|
||||
#define PX_LOAD CAT(vload, PX_LOAD_VEC_SIZE)
|
||||
#define float1 float
|
||||
|
||||
|
||||
inline PX_LOAD_FLOAT_VEC_TYPE readSrcPixelGroup(int2 pos, __global const uchar * srcptr,
|
||||
int srcstep, const struct RectCoords srcCoords)
|
||||
@@ -218,12 +193,150 @@ inline PX_LOAD_FLOAT_VEC_TYPE readSrcPixelGroup(int2 pos, __global const uchar *
|
||||
|
||||
#define LOOP(N, VAR, STMT) CAT(LOOP, N)((VAR), (STMT))
|
||||
|
||||
__kernel void boxFilterSmall(__global const uchar * srcptr, int src_step, int srcOffsetX, int srcOffsetY, int srcEndX, int srcEndY,
|
||||
__global uchar * dstptr, int dst_step, int dst_offset, int rows, int cols
|
||||
#ifdef NORMALIZE
|
||||
, float alpha
|
||||
#ifdef OP_BOX_FILTER
|
||||
#define PROCESS_ELEM \
|
||||
WT total_sum = (WT)(0); \
|
||||
int sy = 0; \
|
||||
LOOP(KERNEL_SIZE_Y, sy, \
|
||||
{ \
|
||||
int sx = 0; \
|
||||
LOOP(KERNEL_SIZE_X, sx, \
|
||||
{ \
|
||||
total_sum += privateData[py + sy][px + sx]; \
|
||||
}); \
|
||||
})
|
||||
|
||||
#elif defined OP_FILTER2D
|
||||
|
||||
#define DIG(a) a,
|
||||
__constant WT1 kernelData[] = { COEFF };
|
||||
|
||||
#define PROCESS_ELEM \
|
||||
WT total_sum = 0; \
|
||||
int sy = 0; \
|
||||
int kernelIndex = 0; \
|
||||
LOOP(KERNEL_SIZE_Y, sy, \
|
||||
{ \
|
||||
int sx = 0; \
|
||||
LOOP(KERNEL_SIZE_X, sx, \
|
||||
{ \
|
||||
total_sum = fma(kernelData[kernelIndex++], privateData[py + sy][px + sx], total_sum); \
|
||||
}); \
|
||||
})
|
||||
|
||||
#elif defined OP_ERODE || defined OP_DILATE
|
||||
|
||||
#ifdef DEPTH_0
|
||||
#define MIN_VAL 0
|
||||
#define MAX_VAL UCHAR_MAX
|
||||
#elif defined DEPTH_1
|
||||
#define MIN_VAL SCHAR_MIN
|
||||
#define MAX_VAL SCHAR_MAX
|
||||
#elif defined DEPTH_2
|
||||
#define MIN_VAL 0
|
||||
#define MAX_VAL USHRT_MAX
|
||||
#elif defined DEPTH_3
|
||||
#define MIN_VAL SHRT_MIN
|
||||
#define MAX_VAL SHRT_MAX
|
||||
#elif defined DEPTH_4
|
||||
#define MIN_VAL INT_MIN
|
||||
#define MAX_VAL INT_MAX
|
||||
#elif defined DEPTH_5
|
||||
#define MIN_VAL (-FLT_MAX)
|
||||
#define MAX_VAL FLT_MAX
|
||||
#elif defined DEPTH_6
|
||||
#define MIN_VAL (-DBL_MAX)
|
||||
#define MAX_VAL DBL_MAX
|
||||
#endif
|
||||
)
|
||||
|
||||
#ifdef OP_ERODE
|
||||
#define VAL (WT)MAX_VAL
|
||||
#elif defined OP_DILATE
|
||||
#define VAL (WT)MIN_VAL
|
||||
#else
|
||||
#error "Unknown operation"
|
||||
#endif
|
||||
|
||||
#define convert_float1 convert_float
|
||||
#define convert_uchar1 convert_uchar
|
||||
#define convert_int1 convert_int
|
||||
#define convert_uint1 convert_uint
|
||||
|
||||
#ifdef OP_ERODE
|
||||
#if defined INTEL_DEVICE && defined DEPTH_0
|
||||
// workaround for bug in Intel HD graphics drivers (10.18.10.3496 or older)
|
||||
#define WA_CONVERT_1 CAT(convert_uint, cn)
|
||||
#define WA_CONVERT_2 CAT(convert_, srcT)
|
||||
#define MORPH_OP(A, B) WA_CONVERT_2(min(WA_CONVERT_1(A), WA_CONVERT_1(B)))
|
||||
#else
|
||||
#define MORPH_OP(A, B) min((A), (B))
|
||||
#endif
|
||||
#endif
|
||||
#ifdef OP_DILATE
|
||||
#define MORPH_OP(A, B) max((A), (B))
|
||||
#endif
|
||||
|
||||
#define PROCESS(_y, _x) \
|
||||
total_sum = convertToWT(MORPH_OP(convertToWT(total_sum), convertToWT(privateData[py + _y][px + _x])));
|
||||
|
||||
#define PROCESS_ELEM \
|
||||
WT total_sum = convertToWT(VAL); \
|
||||
PROCESS_ELEM_
|
||||
|
||||
#else
|
||||
#error "No processing is specified"
|
||||
#endif
|
||||
|
||||
#if defined OP_GRADIENT || defined OP_TOPHAT || defined OP_BLACKHAT
|
||||
#define EXTRA_PARAMS , __global const uchar * matptr, int mat_step, int mat_offset
|
||||
#else
|
||||
#define EXTRA_PARAMS
|
||||
#endif
|
||||
|
||||
inline WT getBorderPixel(const struct RectCoords bounds, int2 coord,
|
||||
__global const uchar * srcptr, int srcstep)
|
||||
{
|
||||
#ifdef BORDER_CONSTANT
|
||||
#ifdef OP_ERODE
|
||||
return (WT)(MAX_VAL);
|
||||
#elif defined OP_DILATE
|
||||
return (WT)(MIN_VAL);
|
||||
#else
|
||||
return (WT)(0);
|
||||
#endif
|
||||
#else
|
||||
|
||||
int selected_col = coord.x;
|
||||
int selected_row = coord.y;
|
||||
|
||||
EXTRAPOLATE(selected_col, selected_row,
|
||||
bounds.x1, bounds.y1,
|
||||
bounds.x2, bounds.y2);
|
||||
|
||||
__global const uchar* ptr = srcptr + mad24(selected_row, srcstep, selected_col * SRCSIZE);
|
||||
return convertToWT(loadpix(ptr));
|
||||
#endif
|
||||
}
|
||||
|
||||
inline WT readSrcPixelSingle(int2 pos, __global const uchar * srcptr,
|
||||
int srcstep, const struct RectCoords srcCoords)
|
||||
{
|
||||
if (!isBorder(srcCoords, pos, 1))
|
||||
{
|
||||
__global const uchar * ptr = srcptr + mad24(pos.y, srcstep, pos.x * SRCSIZE);
|
||||
return convertToWT(loadpix(ptr));
|
||||
}
|
||||
else
|
||||
return getBorderPixel(srcCoords, pos, srcptr, srcstep);
|
||||
}
|
||||
|
||||
|
||||
__kernel void filterSmall(__global const uchar * srcptr, int src_step, int srcOffsetX, int srcOffsetY, int srcEndX, int srcEndY,
|
||||
__global uchar * dstptr, int dst_step, int dst_offset, int rows, int cols
|
||||
#ifdef NORMALIZE
|
||||
, float alpha
|
||||
#endif
|
||||
EXTRA_PARAMS )
|
||||
{
|
||||
// for non-isolated border: offsetX, offsetY, wholeX, wholeY
|
||||
const struct RectCoords srcCoords = { srcOffsetX, srcOffsetY, srcEndX, srcEndY };
|
||||
@@ -282,24 +395,27 @@ __kernel void boxFilterSmall(__global const uchar * srcptr, int src_step, int sr
|
||||
LOOP(PX_PER_WI_X, px,
|
||||
{
|
||||
int x = startX + px;
|
||||
int sy = 0;
|
||||
int kernelIndex = 0;
|
||||
WT total_sum = (WT)(0);
|
||||
|
||||
LOOP(KERNEL_SIZE_Y, sy,
|
||||
{
|
||||
int sx = 0;
|
||||
LOOP(KERNEL_SIZE_X, sx,
|
||||
{
|
||||
total_sum += privateData[py + sy][px + sx];
|
||||
});
|
||||
});
|
||||
|
||||
__global dstT * dstPtr = (__global dstT *)(dstptr + mad24(y, dst_step, mad24(x, DSTSIZE, dst_offset)));
|
||||
PROCESS_ELEM;
|
||||
int dst_index = mad24(y, dst_step, mad24(x, DSTSIZE, dst_offset));
|
||||
__global dstT * dstPtr = (__global dstT *)(dstptr + dst_index);
|
||||
#ifdef NORMALIZE
|
||||
total_sum *= (WT)(alpha);
|
||||
#endif
|
||||
#if defined OP_GRADIENT || defined OP_TOPHAT || defined OP_BLACKHAT
|
||||
//for this type of operations SRCSIZE == DSTSIZE
|
||||
int mat_index = mad24(y, mat_step, mad24(x, SRCSIZE, mat_offset));
|
||||
WT value = convertToWT(loadpix(matptr + mat_index));
|
||||
|
||||
#ifdef OP_GRADIENT
|
||||
storepix(convertToDstT(convertToWT(total_sum) - convertToWT(value)), dstPtr );
|
||||
#elif defined OP_TOPHAT
|
||||
storepix(convertToDstT(convertToWT(value) - convertToWT(total_sum)), dstPtr );
|
||||
#elif defined OP_BLACKHAT
|
||||
storepix(convertToDstT(convertToWT(total_sum) - convertToWT(value)), dstPtr );
|
||||
#endif
|
||||
#else // erode or dilate, or open-close
|
||||
storepix(convertToDstT(total_sum), dstPtr);
|
||||
#endif
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
#define noconvert
|
||||
|
||||
__kernel void calculate_histogram(__global const uchar * src, int src_step, int src_offset, int src_rows, int src_cols,
|
||||
__kernel void calculate_histogram(__global const uchar * src_ptr, int src_step, int src_offset, int src_rows, int src_cols,
|
||||
__global uchar * histptr, int total)
|
||||
{
|
||||
int lid = get_local_id(0);
|
||||
@@ -61,6 +61,7 @@ __kernel void calculate_histogram(__global const uchar * src, int src_step, int
|
||||
localhist[i] = 0;
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
|
||||
__global const uchar * src = src_ptr + src_offset;
|
||||
int src_index;
|
||||
|
||||
for (int grain = HISTS_COUNT * WGS * kercn; id < total; id += grain)
|
||||
@@ -68,7 +69,7 @@ __kernel void calculate_histogram(__global const uchar * src, int src_step, int
|
||||
#ifdef HAVE_SRC_CONT
|
||||
src_index = id;
|
||||
#else
|
||||
src_index = mad24(id / src_cols, src_step, src_offset + id % src_cols);
|
||||
src_index = mad24(id / src_cols, src_step, id % src_cols);
|
||||
#endif
|
||||
|
||||
#if kercn == 1
|
||||
|
||||
@@ -132,8 +132,11 @@ kernel void integral_sum_rows(__global const uchar *buf_ptr, int buf_step, int b
|
||||
}
|
||||
dst_sq_offset += dst_sq_step;
|
||||
|
||||
dst_sq = (__global sumSQT *)(dst_sq_ptr + mad24(x, dst_sq_step, dst_sq_offset));
|
||||
dst_sq[0] = 0;
|
||||
if (x < rows - 1)
|
||||
{
|
||||
dst_sq = (__global sumSQT *)(dst_sq_ptr + mad24(x, dst_sq_step, dst_sq_offset));
|
||||
dst_sq[0] = 0;
|
||||
}
|
||||
|
||||
int buf_sq_index = mad24((int)sizeof(sumSQT), x, buf_sq_offset);
|
||||
sumSQT accum_sq = 0;
|
||||
|
||||
@@ -90,11 +90,8 @@ __kernel void calcSum(__global const uchar * srcptr, int src_step, int src_offse
|
||||
T src = loadpix(srcptr + src_index);
|
||||
|
||||
tmp = convertToWT(src);
|
||||
#if wdepth == 4
|
||||
accumulator = mad24(tmp, tmp, accumulator);
|
||||
#else
|
||||
|
||||
accumulator = mad(tmp, tmp, accumulator);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (lid < WGS2_ALIGNED)
|
||||
@@ -165,11 +162,9 @@ __kernel void matchTemplate_Naive_CCORR(__global const uchar * srcptr, int src_s
|
||||
{
|
||||
T temp = (T)(template[j]);
|
||||
T src = *(__global const T*)(srcptr + ind + j*(int)sizeof(T1));
|
||||
#if wdepth == 4
|
||||
sum = mad24(convertToWT(src), convertToWT(temp), sum);
|
||||
#else
|
||||
sum = mad(convertToWT(src), convertToWT(temp), sum);
|
||||
#endif
|
||||
|
||||
sum = mad(convertToWT(src), convertToWT(temp), sum);
|
||||
|
||||
}
|
||||
ind += src_step;
|
||||
template = (__global const T1 *)((__global const uchar *)template + template_step);
|
||||
@@ -195,12 +190,7 @@ __kernel void matchTemplate_Naive_CCORR(__global const uchar * srcptr, int src_s
|
||||
#pragma unroll
|
||||
for (int cx=0, x = x0; cx < PIX_PER_WI_X && x < dst_cols; ++cx, ++x)
|
||||
{
|
||||
|
||||
#if wdepth == 4
|
||||
sum[cx] = mad24(convertToWT1(src[j+cx]), convertToWT1(template[j]), sum[cx]);
|
||||
#else
|
||||
sum[cx] = mad(convertToWT1(src[j+cx]), convertToWT1(template[j]), sum[cx]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,11 +227,8 @@ __kernel void matchTemplate_Naive_CCORR(__global const uchar * srcptr, int src_s
|
||||
{
|
||||
T src = loadpix(srcptr + mad24(y+i, src_step, mad24(x+j, TSIZE, src_offset)));
|
||||
T template = loadpix(templateptr + mad24(i, template_step, mad24(j, TSIZE, template_offset)));
|
||||
#if wdepth == 4
|
||||
sum = mad24(convertToWT(src), convertToWT(template), sum);
|
||||
#else
|
||||
|
||||
sum = mad(convertToWT(src), convertToWT(template), sum);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,11 +283,8 @@ __kernel void matchTemplate_Naive_SQDIFF(__global const uchar * srcptr, int src_
|
||||
T template = loadpix(templateptr + mad24(i, template_step, mad24(j, TSIZE, template_offset)));
|
||||
|
||||
value = convertToWT(src) - convertToWT(template);
|
||||
#if wdepth == 4
|
||||
sum = mad24(value, value, sum);
|
||||
#else
|
||||
|
||||
sum = mad(value, value, sum);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,16 +53,16 @@
|
||||
|
||||
#if defined BORDER_REPLICATE
|
||||
// aaaaaa|abcdefgh|hhhhhhh
|
||||
#define EXTRAPOLATE(x, maxV) clamp(x, 0, maxV-1)
|
||||
#define EXTRAPOLATE(x, maxV) clamp((x), 0, (maxV)-1)
|
||||
#elif defined BORDER_WRAP
|
||||
// cdefgh|abcdefgh|abcdefg
|
||||
#define EXTRAPOLATE(x, maxV) ( (x) + (maxV) ) % (maxV)
|
||||
#elif defined BORDER_REFLECT
|
||||
// fedcba|abcdefgh|hgfedcb
|
||||
#define EXTRAPOLATE(x, maxV) min(((maxV)-1)*2-(x)+1, max((x),-(x)-1) )
|
||||
#define EXTRAPOLATE(x, maxV) clamp(min(((maxV)-1)*2-(x)+1, max((x),-(x)-1) ), 0, (maxV)-1)
|
||||
#elif defined BORDER_REFLECT_101 || defined BORDER_REFLECT101
|
||||
// gfedcb|abcdefgh|gfedcba
|
||||
#define EXTRAPOLATE(x, maxV) min(((maxV)-1)*2-(x), max((x),-(x)) )
|
||||
#define EXTRAPOLATE(x, maxV) clamp(min(((maxV)-1)*2-(x), max((x),-(x)) ), 0, (maxV)-1)
|
||||
#else
|
||||
#error No extrapolation method
|
||||
#endif
|
||||
|
||||
@@ -413,9 +413,9 @@ __kernel void remap_2_32FC1(__global const uchar * srcptr, int src_step, int src
|
||||
__global T * dst = (__global T *)(dstptr + dst_index);
|
||||
|
||||
#if defined BORDER_CONSTANT
|
||||
|
||||
float xf = map1[0], yf = map2[0];
|
||||
int sx = convert_int_sat_rtn(xf), sy = convert_int_sat_rtn(yf);
|
||||
int sx = convert_int_sat_rtz(mad(xf, INTER_TAB_SIZE, 0.5f)) >> INTER_BITS;
|
||||
int sy = convert_int_sat_rtz(mad(yf, INTER_TAB_SIZE, 0.5f)) >> INTER_BITS;
|
||||
|
||||
__constant float * coeffs_x = coeffs + ((convert_int_rte(xf * INTER_TAB_SIZE) & (INTER_TAB_SIZE - 1)) << 1);
|
||||
__constant float * coeffs_y = coeffs + ((convert_int_rte(yf * INTER_TAB_SIZE) & (INTER_TAB_SIZE - 1)) << 1);
|
||||
|
||||
@@ -98,15 +98,15 @@ __kernel void warpAffine(__global const uchar * srcptr, int src_step, int src_of
|
||||
{
|
||||
int round_delta = (AB_SCALE >> 1);
|
||||
|
||||
int X0 = rint(fma(M[0], dx, fma(M[1], dy0, M[2])) * AB_SCALE) + round_delta;
|
||||
int Y0 = rint(fma(M[3], dx, fma(M[4], dy0, M[5])) * AB_SCALE) + round_delta;
|
||||
|
||||
int XSTEP = (int)(M[1] * AB_SCALE);
|
||||
int YSTEP = (int)(M[4] * AB_SCALE);
|
||||
int X0_ = rint(M[0] * dx * AB_SCALE);
|
||||
int Y0_ = rint(M[3] * dx * AB_SCALE);
|
||||
int dst_index = mad24(dy0, dst_step, mad24(dx, pixsize, dst_offset));
|
||||
|
||||
for (int dy = dy0, dy1 = min(dst_rows, dy0 + rowsPerWI); dy < dy1; ++dy, dst_index += dst_step)
|
||||
{
|
||||
int X0 = X0_ + rint(fma(M[1], dy, M[2]) * AB_SCALE) + round_delta;
|
||||
int Y0 = Y0_ + rint(fma(M[4], dy, M[5]) * AB_SCALE) + round_delta;
|
||||
|
||||
short sx = convert_short_sat(X0 >> AB_BITS);
|
||||
short sy = convert_short_sat(Y0 >> AB_BITS);
|
||||
|
||||
@@ -117,9 +117,6 @@ __kernel void warpAffine(__global const uchar * srcptr, int src_step, int src_of
|
||||
}
|
||||
else
|
||||
storepix(scalar, dstptr + dst_index);
|
||||
|
||||
X0 += XSTEP;
|
||||
Y0 += YSTEP;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -376,4 +373,4 @@ __kernel void warpAffine(__global const uchar * srcptr, int src_step, int src_of
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -41,7 +41,7 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencl_kernels.hpp"
|
||||
#include "opencl_kernels_imgproc.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
@@ -413,6 +413,9 @@ static bool ocl_pyrDown( InputArray _src, OutputArray _dst, const Size& _dsz, in
|
||||
|
||||
Size ssize = _src.size();
|
||||
Size dsize = _dsz.area() == 0 ? Size((ssize.width + 1) / 2, (ssize.height + 1) / 2) : _dsz;
|
||||
if (dsize.height < 2 || dsize.width < 2)
|
||||
return false;
|
||||
|
||||
CV_Assert( ssize.width > 0 && ssize.height > 0 &&
|
||||
std::abs(dsize.width*2 - ssize.width) <= 2 &&
|
||||
std::abs(dsize.height*2 - ssize.height) <= 2 );
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencl_kernels.hpp"
|
||||
#include "opencl_kernels_imgproc.hpp"
|
||||
|
||||
/*
|
||||
* This file includes the code, contributed by Simon Perreault
|
||||
@@ -720,7 +720,7 @@ static bool ocl_boxFilter( InputArray _src, OutputArray _dst, int ddepth,
|
||||
"-D PX_PER_WI_X=%d -D PX_PER_WI_Y=%d -D PRIV_DATA_WIDTH=%d -D %s -D %s "
|
||||
"-D PX_LOAD_X_ITERATIONS=%d -D PX_LOAD_Y_ITERATIONS=%d "
|
||||
"-D srcT=%s -D srcT1=%s -D dstT=%s -D dstT1=%s -D WT=%s -D WT1=%s "
|
||||
"-D convertToWT=%s -D convertToDstT=%s%s%s",
|
||||
"-D convertToWT=%s -D convertToDstT=%s%s%s -D OP_BOX_FILTER",
|
||||
cn, anchor.x, anchor.y, ksize.width, ksize.height,
|
||||
pxLoadVecSize, pxLoadNumPixels,
|
||||
pxPerWorkItemX, pxPerWorkItemY, privDataWidth, borderMap[borderType],
|
||||
@@ -734,7 +734,7 @@ static bool ocl_boxFilter( InputArray _src, OutputArray _dst, int ddepth,
|
||||
|
||||
|
||||
|
||||
if (!kernel.create("boxFilterSmall", cv::ocl::imgproc::boxFilterSmall_oclsrc, build_options))
|
||||
if (!kernel.create("filterSmall", cv::ocl::imgproc::filterSmall_oclsrc, build_options))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -2172,18 +2172,21 @@ void cv::medianBlur( InputArray _src0, OutputArray _dst, int ksize )
|
||||
} \
|
||||
while ((void)0, 0)
|
||||
|
||||
Ipp32s bufSize;
|
||||
IppiSize dstRoiSize = ippiSize(dst.cols, dst.rows), maskSize = ippiSize(ksize, ksize);
|
||||
if( ksize <= 5 )
|
||||
{
|
||||
Ipp32s bufSize;
|
||||
IppiSize dstRoiSize = ippiSize(dst.cols, dst.rows), maskSize = ippiSize(ksize, ksize);
|
||||
|
||||
int type = src0.type();
|
||||
if (type == CV_8UC1)
|
||||
IPP_FILTER_MEDIAN_BORDER(Ipp8u, ipp8u, 8u_C1R);
|
||||
else if (type == CV_16UC1)
|
||||
IPP_FILTER_MEDIAN_BORDER(Ipp16u, ipp16u, 16u_C1R);
|
||||
else if (type == CV_16SC1)
|
||||
IPP_FILTER_MEDIAN_BORDER(Ipp16s, ipp16s, 16s_C1R);
|
||||
else if (type == CV_32FC1)
|
||||
IPP_FILTER_MEDIAN_BORDER(Ipp32f, ipp32f, 32f_C1R);
|
||||
int type = src0.type();
|
||||
if (type == CV_8UC1)
|
||||
IPP_FILTER_MEDIAN_BORDER(Ipp8u, ipp8u, 8u_C1R);
|
||||
else if (type == CV_16UC1)
|
||||
IPP_FILTER_MEDIAN_BORDER(Ipp16u, ipp16u, 16u_C1R);
|
||||
else if (type == CV_16SC1)
|
||||
IPP_FILTER_MEDIAN_BORDER(Ipp16s, ipp16s, 16s_C1R);
|
||||
else if (type == CV_32FC1)
|
||||
IPP_FILTER_MEDIAN_BORDER(Ipp32f, ipp32f, 32f_C1R);
|
||||
}
|
||||
#undef IPP_FILTER_MEDIAN_BORDER
|
||||
#endif
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencl_kernels.hpp"
|
||||
#include "opencl_kernels_imgproc.hpp"
|
||||
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
static IppStatus sts = ippInit();
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencl_kernels.hpp"
|
||||
#include "opencl_kernels_imgproc.hpp"
|
||||
|
||||
////////////////////////////////////////////////// matchTemplate //////////////////////////////////////////////////////////
|
||||
|
||||
@@ -79,7 +79,7 @@ static bool extractFirstChannel_32F(InputArray _image, OutputArray _result, int
|
||||
static bool sumTemplate(InputArray _src, UMat & result)
|
||||
{
|
||||
int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
|
||||
int wdepth = std::max(CV_32S, depth), wtype = CV_MAKE_TYPE(wdepth, cn);
|
||||
int wdepth = CV_32F, wtype = CV_MAKE_TYPE(wdepth, cn);
|
||||
size_t wgs = ocl::Device::getDefault().maxWorkGroupSize();
|
||||
|
||||
int wgs2_aligned = 1;
|
||||
@@ -89,10 +89,10 @@ static bool sumTemplate(InputArray _src, UMat & result)
|
||||
|
||||
char cvt[40];
|
||||
ocl::Kernel k("calcSum", ocl::imgproc::match_template_oclsrc,
|
||||
format("-D CALC_SUM -D T=%s -D T1=%s -D WT=%s -D cn=%d -D convertToWT=%s -D WGS=%d -D WGS2_ALIGNED=%d -D wdepth=%d",
|
||||
format("-D CALC_SUM -D T=%s -D T1=%s -D WT=%s -D cn=%d -D convertToWT=%s -D WGS=%d -D WGS2_ALIGNED=%d",
|
||||
ocl::typeToStr(type), ocl::typeToStr(depth), ocl::typeToStr(wtype), cn,
|
||||
ocl::convertTypeStr(depth, wdepth, cn, cvt),
|
||||
(int)wgs, wgs2_aligned, wdepth));
|
||||
(int)wgs, wgs2_aligned));
|
||||
if (k.empty())
|
||||
return false;
|
||||
|
||||
@@ -110,12 +110,8 @@ static bool sumTemplate(InputArray _src, UMat & result)
|
||||
|
||||
static bool useNaive(Size size)
|
||||
{
|
||||
if (!ocl::Device::getDefault().isIntel())
|
||||
return true;
|
||||
|
||||
int dft_size = 18;
|
||||
return size.height < dft_size && size.width < dft_size;
|
||||
|
||||
}
|
||||
|
||||
struct ConvolveBuf
|
||||
@@ -129,7 +125,6 @@ struct ConvolveBuf
|
||||
UMat image_block, templ_block, result_data;
|
||||
|
||||
void create(Size image_size, Size templ_size);
|
||||
static Size estimateBlockSize(Size result_size);
|
||||
};
|
||||
|
||||
void ConvolveBuf::create(Size image_size, Size templ_size)
|
||||
@@ -137,19 +132,26 @@ void ConvolveBuf::create(Size image_size, Size templ_size)
|
||||
result_size = Size(image_size.width - templ_size.width + 1,
|
||||
image_size.height - templ_size.height + 1);
|
||||
|
||||
block_size = user_block_size;
|
||||
if (user_block_size.width == 0 || user_block_size.height == 0)
|
||||
block_size = estimateBlockSize(result_size);
|
||||
const double blockScale = 4.5;
|
||||
const int minBlockSize = 256;
|
||||
|
||||
dft_size.width = 1 << int(ceil(std::log(block_size.width + templ_size.width - 1.) / std::log(2.)));
|
||||
dft_size.height = 1 << int(ceil(std::log(block_size.height + templ_size.height - 1.) / std::log(2.)));
|
||||
block_size.width = cvRound(result_size.width*blockScale);
|
||||
block_size.width = std::max( block_size.width, minBlockSize - templ_size.width + 1 );
|
||||
block_size.width = std::min( block_size.width, result_size.width );
|
||||
block_size.height = cvRound(templ_size.height*blockScale);
|
||||
block_size.height = std::max( block_size.height, minBlockSize - templ_size.height + 1 );
|
||||
block_size.height = std::min( block_size.height, result_size.height );
|
||||
|
||||
dft_size.width = getOptimalDFTSize(block_size.width + templ_size.width - 1);
|
||||
dft_size.width = std::max(getOptimalDFTSize(block_size.width + templ_size.width - 1), 2);
|
||||
dft_size.height = getOptimalDFTSize(block_size.height + templ_size.height - 1);
|
||||
if( dft_size.width <= 0 || dft_size.height <= 0 )
|
||||
CV_Error( CV_StsOutOfRange, "the input arrays are too big" );
|
||||
|
||||
// To avoid wasting time doing small DFTs
|
||||
dft_size.width = std::max(dft_size.width, 512);
|
||||
dft_size.height = std::max(dft_size.height, 512);
|
||||
// recompute block size
|
||||
block_size.width = dft_size.width - templ_size.width + 1;
|
||||
block_size.width = std::min( block_size.width, result_size.width);
|
||||
block_size.height = dft_size.height - templ_size.height + 1;
|
||||
block_size.height = std::min( block_size.height, result_size.height );
|
||||
|
||||
image_block.create(dft_size, CV_32F);
|
||||
templ_block.create(dft_size, CV_32F);
|
||||
@@ -164,15 +166,6 @@ void ConvolveBuf::create(Size image_size, Size templ_size)
|
||||
block_size.height = std::min(dft_size.height - templ_size.height + 1, result_size.height);
|
||||
}
|
||||
|
||||
Size ConvolveBuf::estimateBlockSize(Size result_size)
|
||||
{
|
||||
int width = (result_size.width + 2) / 3;
|
||||
int height = (result_size.height + 2) / 3;
|
||||
width = std::min(width, result_size.width);
|
||||
height = std::min(height, result_size.height);
|
||||
return Size(width, height);
|
||||
}
|
||||
|
||||
static bool convolve_dft(InputArray _image, InputArray _templ, OutputArray _result)
|
||||
{
|
||||
ConvolveBuf buf;
|
||||
@@ -202,7 +195,7 @@ static bool convolve_dft(InputArray _image, InputArray _templ, OutputArray _resu
|
||||
copyMakeBorder(templ_roi, templ_block, 0, templ_block.rows - templ_roi.rows, 0,
|
||||
templ_block.cols - templ_roi.cols, BORDER_ISOLATED);
|
||||
|
||||
dft(templ_block, templ_spect, 0);
|
||||
dft(templ_block, templ_spect, 0, templ.rows);
|
||||
|
||||
// Process all blocks of the result matrix
|
||||
for (int y = 0; y < result.rows; y += block_size.height)
|
||||
@@ -281,8 +274,8 @@ static bool matchTemplateNaive_CCORR(InputArray _image, InputArray _templ, Outpu
|
||||
const char* convertToWT = ocl::convertTypeStr(depth, wdepth, rated_cn, cvt1);
|
||||
|
||||
ocl::Kernel k("matchTemplate_Naive_CCORR", ocl::imgproc::match_template_oclsrc,
|
||||
format("-D CCORR -D T=%s -D T1=%s -D WT=%s -D WT1=%s -D convertToWT=%s -D convertToWT1=%s -D cn=%d -D wdepth=%d -D PIX_PER_WI_X=%d", ocl::typeToStr(type), ocl::typeToStr(depth), ocl::typeToStr(wtype1), ocl::typeToStr(wtype),
|
||||
convertToWT, convertToWT1, cn, wdepth, pxPerWIx));
|
||||
format("-D CCORR -D T=%s -D T1=%s -D WT=%s -D WT1=%s -D convertToWT=%s -D convertToWT1=%s -D cn=%d -D PIX_PER_WI_X=%d", ocl::typeToStr(type), ocl::typeToStr(depth), ocl::typeToStr(wtype1), ocl::typeToStr(wtype),
|
||||
convertToWT, convertToWT1, cn, pxPerWIx));
|
||||
if (k.empty())
|
||||
return false;
|
||||
|
||||
@@ -358,8 +351,8 @@ static bool matchTemplateNaive_SQDIFF(InputArray _image, InputArray _templ, Outp
|
||||
|
||||
char cvt[40];
|
||||
ocl::Kernel k("matchTemplate_Naive_SQDIFF", ocl::imgproc::match_template_oclsrc,
|
||||
format("-D SQDIFF -D T=%s -D T1=%s -D WT=%s -D convertToWT=%s -D cn=%d -D wdepth=%d", ocl::typeToStr(type), ocl::typeToStr(depth),
|
||||
ocl::typeToStr(wtype), ocl::convertTypeStr(depth, wdepth, cn, cvt), cn, wdepth));
|
||||
format("-D SQDIFF -D T=%s -D T1=%s -D WT=%s -D convertToWT=%s -D cn=%d", ocl::typeToStr(type), ocl::typeToStr(depth),
|
||||
ocl::typeToStr(wtype), ocl::convertTypeStr(depth, wdepth, cn, cvt), cn));
|
||||
if (k.empty())
|
||||
return false;
|
||||
|
||||
@@ -457,18 +450,18 @@ static bool matchTemplate_CCOEFF(InputArray _image, InputArray _templ, OutputArr
|
||||
|
||||
UMat templ = _templ.getUMat();
|
||||
UMat result = _result.getUMat();
|
||||
Size tsize = templ.size();
|
||||
|
||||
if (cn==1)
|
||||
{
|
||||
float templ_sum = static_cast<float>(sum(_templ)[0]) / tsize.area();
|
||||
Scalar templMean = mean(templ);
|
||||
float templ_sum = (float)templMean[0];
|
||||
|
||||
k.args(ocl::KernelArg::ReadOnlyNoSize(image_sums), ocl::KernelArg::ReadWrite(result), templ.rows, templ.cols, templ_sum);
|
||||
}
|
||||
else
|
||||
{
|
||||
Vec4f templ_sum = Vec4f::all(0);
|
||||
templ_sum = sum(templ) / tsize.area();
|
||||
templ_sum = (Vec4f)mean(templ);
|
||||
|
||||
k.args(ocl::KernelArg::ReadOnlyNoSize(image_sums), ocl::KernelArg::ReadWrite(result), templ.rows, templ.cols, templ_sum); }
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencl_kernels.hpp"
|
||||
#include "opencl_kernels_imgproc.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "../test_precomp.hpp"
|
||||
#include "cvconfig.h"
|
||||
#include "opencv2/ts/ocl_test.hpp"
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "../test_precomp.hpp"
|
||||
#include "cvconfig.h"
|
||||
#include "opencv2/ts/ocl_test.hpp"
|
||||
|
||||
@@ -117,7 +117,7 @@ OCL_TEST_P(BlendLinear, Accuracy)
|
||||
OCL_OFF(cv::blendLinear(src1_roi, src2_roi, weights1_roi, weights2_roi, dst_roi));
|
||||
OCL_ON(cv::blendLinear(usrc1_roi, usrc2_roi, uweights1_roi, uweights2_roi, udst_roi));
|
||||
|
||||
Near(depth <= CV_32S ? 1.0 : 0.2);
|
||||
Near(depth <= CV_32S ? 1.0 : 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "../test_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_test.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
@@ -109,7 +109,7 @@ OCL_TEST_P(BoxFilter, Mat)
|
||||
OCL_OFF(cv::boxFilter(src_roi, dst_roi, -1, ksize, anchor, normalize, borderType));
|
||||
OCL_ON(cv::boxFilter(usrc_roi, udst_roi, -1, ksize, anchor, normalize, borderType));
|
||||
|
||||
Near(depth <= CV_32S ? 1 : 1e-3);
|
||||
Near(depth <= CV_32S ? 1 : 3e-3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "../test_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_test.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "../test_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_test.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
@@ -302,14 +302,14 @@ OCL_TEST_P(CvtColor8u32f, Lab2LRGBA) { performTest(3, 4, CVTCODE(Lab2LRGB), dept
|
||||
|
||||
// RGB -> Luv
|
||||
|
||||
OCL_TEST_P(CvtColor8u32f, BGR2Luv) { performTest(3, 3, CVTCODE(BGR2Luv), depth == CV_8U ? 1 : 1e-2); }
|
||||
OCL_TEST_P(CvtColor8u32f, RGB2Luv) { performTest(3, 3, CVTCODE(RGB2Luv), depth == CV_8U ? 1 : 1e-2); }
|
||||
OCL_TEST_P(CvtColor8u32f, LBGR2Luv) { performTest(3, 3, CVTCODE(LBGR2Luv), depth == CV_8U ? 1 : 4e-3); }
|
||||
OCL_TEST_P(CvtColor8u32f, LRGB2Luv) { performTest(3, 3, CVTCODE(LRGB2Luv), depth == CV_8U ? 1 : 5e-3); }
|
||||
OCL_TEST_P(CvtColor8u32f, BGRA2Luv) { performTest(4, 3, CVTCODE(BGR2Luv), depth == CV_8U ? 1 : 8e-3); }
|
||||
OCL_TEST_P(CvtColor8u32f, RGBA2Luv) { performTest(4, 3, CVTCODE(RGB2Luv), depth == CV_8U ? 1 : 9e-3); }
|
||||
OCL_TEST_P(CvtColor8u32f, LBGRA2Luv) { performTest(4, 3, CVTCODE(LBGR2Luv), depth == CV_8U ? 1 : 5e-3); }
|
||||
OCL_TEST_P(CvtColor8u32f, LRGBA2Luv) { performTest(4, 3, CVTCODE(LRGB2Luv), depth == CV_8U ? 1 : 5e-3); }
|
||||
OCL_TEST_P(CvtColor8u32f, BGR2Luv) { performTest(3, 3, CVTCODE(BGR2Luv), depth == CV_8U ? 1 : 1.5e-2); }
|
||||
OCL_TEST_P(CvtColor8u32f, RGB2Luv) { performTest(3, 3, CVTCODE(RGB2Luv), depth == CV_8U ? 1 : 1.5e-2); }
|
||||
OCL_TEST_P(CvtColor8u32f, LBGR2Luv) { performTest(3, 3, CVTCODE(LBGR2Luv), depth == CV_8U ? 1 : 6e-3); }
|
||||
OCL_TEST_P(CvtColor8u32f, LRGB2Luv) { performTest(3, 3, CVTCODE(LRGB2Luv), depth == CV_8U ? 1 : 6e-3); }
|
||||
OCL_TEST_P(CvtColor8u32f, BGRA2Luv) { performTest(4, 3, CVTCODE(BGR2Luv), depth == CV_8U ? 1 : 2e-2); }
|
||||
OCL_TEST_P(CvtColor8u32f, RGBA2Luv) { performTest(4, 3, CVTCODE(RGB2Luv), depth == CV_8U ? 1 : 2e-2); }
|
||||
OCL_TEST_P(CvtColor8u32f, LBGRA2Luv) { performTest(4, 3, CVTCODE(LBGR2Luv), depth == CV_8U ? 1 : 6e-3); }
|
||||
OCL_TEST_P(CvtColor8u32f, LRGBA2Luv) { performTest(4, 3, CVTCODE(LRGB2Luv), depth == CV_8U ? 1 : 6e-3); }
|
||||
|
||||
OCL_TEST_P(CvtColor8u32f, Luv2BGR) { performTest(3, 3, CVTCODE(Luv2BGR), depth == CV_8U ? 1 : 7e-5); }
|
||||
OCL_TEST_P(CvtColor8u32f, Luv2RGB) { performTest(3, 3, CVTCODE(Luv2RGB), depth == CV_8U ? 1 : 7e-5); }
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "../test_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_test.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
@@ -125,7 +125,7 @@ OCL_INSTANTIATE_TEST_CASE_P(ImageProc, Filter2D,
|
||||
Combine(
|
||||
Values(CV_8U, CV_16U, CV_32F),
|
||||
OCL_ALL_CHANNELS,
|
||||
Values(3, 5, 9), // Kernel size
|
||||
Values(3, 5, 7), // Kernel size
|
||||
Values(1, 4, 8), // Width mutiple
|
||||
Values((BorderType)BORDER_CONSTANT,
|
||||
(BorderType)BORDER_REPLICATE,
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "../test_precomp.hpp"
|
||||
#include "cvconfig.h"
|
||||
#include "opencv2/ts/ocl_test.hpp"
|
||||
|
||||
@@ -225,7 +225,7 @@ OCL_TEST_P(GaussianBlurTest, Mat)
|
||||
OCL_OFF(cv::GaussianBlur(src_roi, dst_roi, Size(ksize, ksize), sigma1, sigma2, borderType));
|
||||
OCL_ON(cv::GaussianBlur(usrc_roi, udst_roi, Size(ksize, ksize), sigma1, sigma2, borderType));
|
||||
|
||||
Near(CV_MAT_DEPTH(type) >= CV_32F ? 5e-5 : 1, false);
|
||||
Near(CV_MAT_DEPTH(type) >= CV_32F ? 7e-5 : 1, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,14 +275,68 @@ OCL_TEST_P(Dilate, Mat)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// MorphologyEx
|
||||
IMPLEMENT_PARAM_CLASS(MorphOp, int)
|
||||
PARAM_TEST_CASE(MorphologyEx, MatType,
|
||||
int, // kernel size
|
||||
MorphOp, // MORPH_OP
|
||||
int, // iterations
|
||||
bool)
|
||||
{
|
||||
int type, ksize, op, iterations;
|
||||
bool useRoi;
|
||||
|
||||
typedef FilterTestBase MorphologyEx;
|
||||
TEST_DECLARE_INPUT_PARAMETER(src);
|
||||
TEST_DECLARE_OUTPUT_PARAMETER(dst);
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
type = GET_PARAM(0);
|
||||
ksize = GET_PARAM(1);
|
||||
op = GET_PARAM(2);
|
||||
iterations = GET_PARAM(3);
|
||||
useRoi = GET_PARAM(4);
|
||||
}
|
||||
|
||||
void random_roi(int minSize = 1)
|
||||
{
|
||||
if (minSize == 0)
|
||||
minSize = ksize;
|
||||
|
||||
Size roiSize = randomSize(minSize, MAX_VALUE);
|
||||
|
||||
Border srcBorder = randomBorder(0, useRoi ? MAX_VALUE : 0);
|
||||
randomSubMat(src, src_roi, roiSize, srcBorder, type, 5, 256);
|
||||
|
||||
Border dstBorder = randomBorder(0, useRoi ? MAX_VALUE : 0);
|
||||
randomSubMat(dst, dst_roi, roiSize, dstBorder, type, -60, 70);
|
||||
|
||||
UMAT_UPLOAD_INPUT_PARAMETER(src);
|
||||
UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
|
||||
}
|
||||
|
||||
void Near()
|
||||
{
|
||||
int depth = CV_MAT_DEPTH(type);
|
||||
bool isFP = depth >= CV_32F;
|
||||
|
||||
if (isFP)
|
||||
Near(1e-6, true);
|
||||
else
|
||||
Near(1, false);
|
||||
}
|
||||
|
||||
void Near(double threshold, bool relative)
|
||||
{
|
||||
if (relative)
|
||||
OCL_EXPECT_MATS_NEAR_RELATIVE(dst, threshold);
|
||||
else
|
||||
OCL_EXPECT_MATS_NEAR(dst, threshold);
|
||||
}
|
||||
};
|
||||
|
||||
OCL_TEST_P(MorphologyEx, Mat)
|
||||
{
|
||||
Size kernelSize(ksize, ksize);
|
||||
int iterations = (int)param;
|
||||
int op = size.height;
|
||||
|
||||
for (int j = 0; j < test_loop_times; j++)
|
||||
{
|
||||
@@ -377,12 +431,10 @@ OCL_INSTANTIATE_TEST_CASE_P(Filter, Dilate, Combine(
|
||||
|
||||
OCL_INSTANTIATE_TEST_CASE_P(Filter, MorphologyEx, Combine(
|
||||
Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4),
|
||||
Values(3, 5, 7),
|
||||
Values(Size(0, 2), Size(0, 3), Size(0, 4), Size(0, 5), Size(0, 6)), // used as generator of operations
|
||||
Values((BorderType)BORDER_CONSTANT),
|
||||
Values(1.0, 2.0, 3.0),
|
||||
Bool(),
|
||||
Values(1))); // not used
|
||||
Values(3, 5, 7), // kernel size
|
||||
Values((MorphOp)MORPH_OPEN, (MorphOp)MORPH_CLOSE, (MorphOp)MORPH_GRADIENT, (MorphOp)MORPH_TOPHAT, (MorphOp)MORPH_BLACKHAT), // used as generator of operations
|
||||
Values(1, 2, 3),
|
||||
Bool()));
|
||||
|
||||
|
||||
} } // namespace cvtest::ocl
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "../test_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_test.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "../test_precomp.hpp"
|
||||
#include "cvconfig.h"
|
||||
#include "opencv2/ts/ocl_test.hpp"
|
||||
|
||||
@@ -99,6 +99,10 @@ PARAM_TEST_CASE(CalcBackProject, MatDepth, int, bool)
|
||||
Size roiSize = randomSize(1, MAX_VALUE);
|
||||
|
||||
int totalChannels = 0;
|
||||
|
||||
ranges.clear();
|
||||
channels.clear();
|
||||
|
||||
for (int i = 0; i < N; ++i)
|
||||
{
|
||||
Border srcBorder = randomBorder(0, useRoi ? MAX_VALUE : 0);
|
||||
@@ -202,9 +206,9 @@ OCL_TEST_P(CalcBackProject, Mat)
|
||||
OCL_ON(cv::calcBackProject(uimages_roi, channels, uhist_roi, udst_roi, ranges, scale));
|
||||
|
||||
Size dstSize = dst_roi.size();
|
||||
int nDiffs = (int)(0.03f*dstSize.height*dstSize.width);
|
||||
int nDiffs = std::max((int)(0.07f*dstSize.area()), 1);
|
||||
|
||||
//check if the dst mats are the same except 3% difference
|
||||
//check if the dst mats are the same except 7% difference
|
||||
EXPECT_MAT_N_DIFF(dst_roi, udst_roi, nDiffs);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "../test_precomp.hpp"
|
||||
#include "cvconfig.h"
|
||||
#include "opencv2/ts/ocl_test.hpp"
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "../test_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_test.hpp"
|
||||
#include "iostream"
|
||||
#include "fstream"
|
||||
@@ -97,9 +97,17 @@ PARAM_TEST_CASE(MatchTemplate, MatDepth, Channels, MatchTemplType, bool)
|
||||
UMAT_UPLOAD_OUTPUT_PARAMETER(result);
|
||||
}
|
||||
|
||||
void Near(double threshold = 0.0)
|
||||
void Near()
|
||||
{
|
||||
OCL_EXPECT_MATS_NEAR_RELATIVE(result, threshold);
|
||||
bool isNormed =
|
||||
method == TM_CCORR_NORMED ||
|
||||
method == TM_SQDIFF_NORMED ||
|
||||
method == TM_CCOEFF_NORMED;
|
||||
|
||||
if (isNormed)
|
||||
OCL_EXPECT_MATS_NEAR(result, 3e-2);
|
||||
else
|
||||
OCL_EXPECT_MATS_NEAR_RELATIVE_SPARSE(result, 1.5e-2);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -112,7 +120,7 @@ OCL_TEST_P(MatchTemplate, Mat)
|
||||
OCL_OFF(cv::matchTemplate(image_roi, templ_roi, result_roi, method));
|
||||
OCL_ON(cv::matchTemplate(uimage_roi, utempl_roi, uresult_roi, method));
|
||||
|
||||
Near(1.5e-4);
|
||||
Near();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "../test_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_test.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
//M*/
|
||||
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "../test_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_test.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "../test_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_test.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "../test_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_test.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
@@ -182,7 +182,7 @@ PARAM_TEST_CASE(Resize, MatType, double, double, Interpolation, bool, int)
|
||||
{
|
||||
CV_Assert(fx > 0 && fy > 0);
|
||||
|
||||
Size srcRoiSize = randomSize(1, MAX_VALUE), dstRoiSize;
|
||||
Size srcRoiSize = randomSize(10, MAX_VALUE), dstRoiSize;
|
||||
// Make sure the width is a multiple of the requested value, and no more
|
||||
srcRoiSize.width += widthMultiple - 1 - (srcRoiSize.width - 1) % widthMultiple;
|
||||
dstRoiSize.width = cvRound(srcRoiSize.width * fx);
|
||||
@@ -215,7 +215,7 @@ OCL_TEST_P(Resize, Mat)
|
||||
for (int j = 0; j < test_loop_times; j++)
|
||||
{
|
||||
int depth = CV_MAT_DEPTH(type);
|
||||
double eps = depth <= CV_32S ? 1 : 1e-2;
|
||||
double eps = depth <= CV_32S ? 1 : 5e-2;
|
||||
|
||||
random_roi();
|
||||
|
||||
|
||||
@@ -228,7 +228,7 @@ int CV_MorphologyBaseTest::prepare_test_case( int test_case_idx )
|
||||
if( shape == CV_SHAPE_CUSTOM )
|
||||
{
|
||||
eldata.resize(aperture_size.width*aperture_size.height);
|
||||
uchar* src = test_mat[INPUT][1].data;
|
||||
const uchar* src = test_mat[INPUT][1].data;
|
||||
int srcstep = (int)test_mat[INPUT][1].step;
|
||||
int i, j, nonzero = 0;
|
||||
|
||||
|
||||
@@ -344,7 +344,7 @@ static void test_remap( const Mat& src, Mat& dst, const Mat& mapx, const Mat& ma
|
||||
int x, y, k;
|
||||
int drows = dst.rows, dcols = dst.cols;
|
||||
int srows = src.rows, scols = src.cols;
|
||||
uchar* sptr0 = src.data;
|
||||
const uchar* sptr0 = src.data;
|
||||
int depth = src.depth(), cn = src.channels();
|
||||
int elem_size = (int)src.elemSize();
|
||||
int step = (int)(src.step / CV_ELEM_SIZE(depth));
|
||||
|
||||
@@ -532,7 +532,7 @@ void CV_Resize_Test::resize_1d(const Mat& _src, Mat& _dst, int dy, const dim& _d
|
||||
ofs = 3, ksize = 8;
|
||||
|
||||
Mat _extended_src_row(1, _src.cols + ksize * 2, _src.type());
|
||||
uchar* srow = _src.data + dy * _src.step;
|
||||
const uchar* srow = _src.ptr(dy);
|
||||
memcpy(_extended_src_row.data + elemsize * ksize, srow, _src.step);
|
||||
for (int k = 0; k < ksize; ++k)
|
||||
{
|
||||
|
||||