Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
61b94841
Commit
61b94841
authored
Dec 15, 2016
by
LaurentBerger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ApplyColorMap can be used with a user colormap
parent
36b5abf6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
1 deletion
+42
-1
imgproc.hpp
modules/imgproc/include/opencv2/imgproc.hpp
+9
-1
colormap.cpp
modules/imgproc/src/colormap.cpp
+33
-0
No files found.
modules/imgproc/include/opencv2/imgproc.hpp
View file @
61b94841
...
...
@@ -4097,9 +4097,17 @@ enum ColormapTypes
@param src The source image, grayscale or colored of type CV_8UC1 or CV_8UC3.
@param dst The result is the colormapped source image. Note: Mat::create is called on dst.
@param colormap The colormap to apply, see cv::ColormapTypes
*/
*/
CV_EXPORTS_W
void
applyColorMap
(
InputArray
src
,
OutputArray
dst
,
int
colormap
);
/** @brief Applies a user colormap on a given image.
@param src The source image, grayscale or colored of type CV_8UC1 or CV_8UC3.
@param dst The result is the colormapped source image. Note: Mat::create is called on dst.
@param userColor The colormap to apply of type CV_8UC1 or CV_8UC3 and size 256
*/
CV_EXPORTS_W
void
applyColorMap
(
InputArray
src
,
OutputArray
dst
,
InputArray
userColor
);
//! @} imgproc_colormap
//! @addtogroup imgproc_draw
...
...
modules/imgproc/src/colormap.cpp
View file @
61b94841
...
...
@@ -490,6 +490,22 @@ namespace colormap
}
};
// UserColormap .
class
UserColorMap
:
public
ColorMap
{
public
:
UserColorMap
(
Mat
c
)
:
ColorMap
()
{
init
(
c
);
}
void
init
(
Mat
c
)
{
this
->
_lut
=
c
;
}
void
init
(
int
n
)
{
CV_Error
(
Error
::
StsAssert
,
"unused method in UserColormap."
);
}
};
void
ColorMap
::
operator
()(
InputArray
_src
,
OutputArray
_dst
)
const
{
CV_INSTRUMENT_REGION
()
...
...
@@ -546,4 +562,21 @@ namespace colormap
delete
cm
;
}
void
applyColorMap
(
InputArray
src
,
OutputArray
dst
,
InputArray
userColor
)
{
if
(
userColor
.
total
()
!=
256
)
CV_Error
(
Error
::
StsAssert
,
"cv::LUT only supports tables of size 256."
);
if
(
userColor
.
type
()
!=
CV_8UC1
&&
userColor
.
type
()
!=
CV_8UC3
)
CV_Error
(
Error
::
StsAssert
,
"cv::LUT only supports tables CV_8UC1 or CV_8UC3."
);
colormap
::
ColorMap
*
cm
=
(
colormap
::
ColorMap
*
)
(
new
colormap
::
UserColorMap
(
userColor
.
getMat
()));
if
(
!
cm
)
CV_Error
(
Error
::
StsBadArg
,
"Unknown colormap id; use one of COLORMAP_*"
);
(
*
cm
)(
src
,
dst
);
delete
cm
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment