Ask Your Question
0

How to create a custom colormap

asked 2015-03-18 12:26:39 -0600

sitzikbs gravatar image

Hi, im very new to openCV. I am converting a disparity map to an rgb image with a colormap overlay (the different colors represent distance). I use this function

applyColorMap(adjMap, RGBImage, cv::COLORMAP_JET);

wher adjMap is the grayscale image RGBImage is the final RGBimage i wanted and COLORMAP_JET is the colormap

I wish to change the colors in the colormap, so my quetion is - is it possible to create a customized colormap ? and if so - how?

edit retag flag offensive close merge delete

Comments

Maybe this answer can help: http://answers.opencv.org/question/50...

kbarni gravatar imagekbarni ( 2015-03-19 05:10:43 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
3

answered 2015-03-19 01:37:49 -0600

wuling gravatar image

updated 2015-03-19 01:58:12 -0600

Hi if you want to make custom colormap,please follow step: At first step make a table[3x255] or 3 table [1x255]. Second step the source should be convert 3 dimenision, and use LUT,like:

    for(int i=0;i<256;i++)
    {
      M1.at<uchar>(i)=Luta[i][0];
      M2.at<uchar>(i)=Luta[i][1];
     M3.at<uchar>(i)=Luta[i][2];
    }

     Mat r1,r2,r3;

    cv::LUT(temp,M1,r1);
    cv::LUT(temp,M2,r2);
    cv::LUT(temp,M3,r3);
    std::vector<cv::Mat> planes;
    planes.push_back(r1);
    planes.push_back(r2);
    planes.push_back(r3);

    cv::merge(planes,dst);

Third step: merge

I hope you can make it!

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-03-18 12:26:39 -0600

Seen: 6,524 times

Last updated: Mar 19 '15