1 | initial version |
If you need coloring for display, you have to create a copy of the Mat, then convert it to a three channel image (type CV_8UC3) and play with the channels. Don't touch the original kernel, because it won't work after.
But probably you want only to apply a color map. This is the simplest solution for this problem.
Here is what you should do:
Mat kernel_byte,kernel_color;
kernel.convertTo(kernel_byte,CV_8U,128,128); // check the last two parameters
// for correct normalization
applyColorMap(kernel_byte, kernel_color, COLORMAP_JET);
Here is a tutorial about color maps: Tutorial
2 | No.2 Revision |
If you need coloring for display, you have to create a copy of the Mat, then convert it to a three channel image (type CV_8UC3) and play with the channels. Don't touch the original kernel, because it won't work after.
But probably you want only to apply a color map. This is the simplest solution for this problem.
Here is what you should do:
Mat kernel_byte,kernel_color;
kernel_byte = new Mat(), kernel_color = new Mat();
kernel.convertTo(kernel_byte,CV_8U,128,128); // check the last two parameters
// for correct normalization
applyColorMap(kernel_byte, kernel_color, COLORMAP_JET);
Here is a tutorial about color maps: Tutorial
3 | No.3 Revision |
If you need coloring for display, you have to create a copy of the Mat, then convert it to a three channel image (type CV_8UC3) and play with the channels. Don't touch the original kernel, because it won't work after.
But probably you want only to apply a color map. This is the simplest solution for this problem.
Here is what you should do:
Mat kernel_byte = new Mat(), kernel_color = new Mat();
kernel.convertTo(kernel_byte,CV_8U,128,128); // check the last two parameters
// for correct normalization
applyColorMap(kernel_byte, Imgproc.applyColorMap(kernel_byte, kernel_color, COLORMAP_JET);
Imgproc.COLORMAP_JET);
Here is a tutorial about color maps: Tutorial