c++ - building an image from Mat object in OpenCV -
im using opencv , have mat object of size 1024*1024(extracted photo , manipulated) , values in range [1..25].for example:
mat g; g=[1,5,2,14,13,5,22,24,5,13....; 21,12,...; .. .];
i want represent these values image.it illustration image show different areas,each area color. example: values equals 1=red, values equals 14=blue, , on..
and construct , display photo.
anybody have idea how should proceed?
thanks!
there colormaps , won't if data in [0..25] range only. ned roll own version of that:
vec3b lut[26] = { vec3b(0,0,255), vec3b(13,255,11), vec3b(255,22,1), // way down, picture, no ? }; mat color(w,h,cv_8uc3); ( int y=0; y<h; y++ ) { ( int x=0; x<w; x++ ) { color.at<vec3b>(y,x) = lut[ g.at<uchar>(y,x) ]; // check type of "g" please, assumed cv_8uc1 here. // if it's cv_32s, use g.at<int> , i.e, need right type here } }
Comments
Post a Comment