5/25/2018

example for applyColorMap usage

example for applyColorMap usage

...
#include "opencv2/opencv.hpp"
#include "opencv2/cuda.hpp"
#include "opencv2\cudaarithm.hpp"
#include <iostream>
#include <time.h>

using namespace std;
using namespace cv;

int main()
{
    
    //image show.
    Mat img = imread("AbyssCGI.jpg");
    
    namedWindow("img", 0);
    imshow("img", img);

    /////////////////applyColorMap
    //basic usage
    Mat im_color;
    applyColorMap(img, im_color, COLORMAP_COOL);//COLORMAP_AUTUMN);
    namedWindow("im_color", 0);
    imshow("im_color", im_color);

    //what about gray?
    Mat img_gray;
    cvtColor(img, img_gray, CV_RGB2GRAY);
    Mat im_color2;
    applyColorMap(img_gray, im_color2, COLORMAP_AUTUMN);
    namedWindow("im_color2", 0);
    imshow("im_color2", im_color2);
    /////////////////////////////////////////

    //////////////////// gray & color test!!
    Mat img2(100, 100, CV_8UC3);
    img2.setTo(Scalar(0, 128, 255));
    Mat im_color3;
    applyColorMap(img2, im_color3, COLORMAP_JET);

    namedWindow("im_color3", 0);
    imshow("im_color3", im_color3);

    //same with resutl of color
    Mat img2_gray;
    cvtColor(img2, img2_gray, CV_RGB2GRAY);
    Mat im_color4;
    applyColorMap(img2, im_color4, COLORMAP_JET);
    namedWindow("im_color4", 0);
    imshow("im_color4", im_color4);
    //////////////////////

    waitKey(0);

    return 0;
}
...


No comments:

Post a Comment