Ask Your Question
0

Combine a color Image to Gray image

asked 2016-09-24 08:31:06 -0600

greenworld gravatar image

updated 2016-09-24 08:57:15 -0600

LBerger gravatar image

Dear everyone,

Mat Gray; //gray scale
Mat drawing = Mat::zeros(imgThresholded.size(), CV_8UC3); //color

on drawing image, I gonna draw some lines, points, I want to merge them to the Gray, and display the Gray image. Could you please help. Thank you!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-09-24 09:10:18 -0600

LBerger gravatar image

updated 2016-09-24 09:10:51 -0600

In color a grayscale image values in plane BGR are equal:

Mat Gray = imread("f:/lib/opencv/samples/data/lena.jpg",IMREAD_GRAYSCALE);
Mat grayInColor;
Mat drawing = Mat::zeros(Gray.size(), CV_8UC3); //color
line(drawing, Point(0, 0), Point(256, 256), Vec3b(255,0,255),3);

vector<Mat> plan;

plan.push_back(Gray);
plan.push_back(Gray);
plan.push_back(Gray);
// Then you can merge  
merge(plan,grayInColor);
Mat result;

addWeighted(grayInColor, 0.5, drawing, 0.5, 0, result);
imshow("result",result);
waitKey();
edit flag offensive delete link more

Comments

Thank you!

greenworld gravatar imagegreenworld ( 2016-09-24 10:59:50 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-09-24 08:31:06 -0600

Seen: 1,144 times

Last updated: Sep 24 '16