【发布时间】:2017-08-10 06:38:34
【问题描述】:
S对不起我的英语不好。我有一个图像,显示 3 个不同颜色的圆圈,一个红色、一个绿色和一个蓝色,我可以将此图像显示到 3 个通道中,但它们显示为白色,在代码中我显示一个名为“复制 R”的图像,我不知道如何将这个副本 R 变成另一个图像,我想用任何颜色重叠原始图像并改变红色。我该怎么做???
这是我的代码,抱歉是我第一次提出问题,不知道如何正确发布
#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#define w 400
using namespace cv;
/// 函数头
void MyFilledCircle(Mat img, Point center);
void MyFilledCircle1(Mat img, Point center);
void MyFilledCircle2(Mat img, Point center);
int main(void) {
//![create_images]
char window[] = "Original";
/// Create black empty images
Mat image = Mat::zeros(w, w, CV_8UC3);
/// 1.b. Creating circles
MyFilledCircle(image, Point(200, 200));
MyFilledCircle1(image, Point(150, 150));
MyFilledCircle2(image, Point(250, 250));
Mat channel[3];
split(image, channel);
//channel[0] = Mat::zeros(image.rows, image.cols, CV_8UC1);
merge(channel, 3, image);
Mat imageHSV;
Mat copy;
imshow(window, image);
//imshow("Color 1", imageHSV);
inRange(image, Scalar(0, 0, 255), Scalar(0, 0, 255), copy);
imshow("copy R", copy);
imshow("B", channel[0]);
imshow("G", channel[1]);
imshow("R", channel[2]);
//imshow("0", canal0);
//imwrite("dest.jpg", image);
waitKey(0);
return(0);
}
/// Function Declaration
//![myfilledcircle]
void MyFilledCircle1(Mat img, Point center)
{
circle(img,
center,
50,
Scalar(0, 255, 0),
FILLED,
LINE_8);
}
void MyFilledCircle(Mat img, Point center)
{
circle(img,
center,
50,
Scalar(0, 0, 255),
FILLED,
LINE_8);
}
void MyFilledCircle2(Mat img, Point center)
{
circle(img,
center,
50,
Scalar(255, 0, 0),
FILLED,
LINE_8);
}
【问题讨论】:
-
改变
Scalar类型里面的数字,你会得到不同的颜色。 -
如果你的意思是在 te inrange 操作中改变标量的值,我已经试过了,还是不行
标签: c++ opencv visual-studio-2015 colors