image - 从输入图像获取RGB像素并在opencv中重建输出图像

标签 image opencv rgb

我想在opencv中加载图像并将图像拆分为channels(RGB),我想增加任何一种颜色并获取相应的输出图像。有没有最简单的方法来解决此问题?

最佳答案

要将任何标量添加到RGB图像,可以使用cvAddS(srcImage,scalarToAdd,dstImage)。
这是一个例子:

int main(int argc, char** argv)

{
// Create a named window with the name of the file.
cvNamedWindow( argv[1], 1 );
// Load the image from the given file name.
IplImage* img = cvLoadImage( argv[1] );
//Make a scalar to add 30 to Blue Color and 20 to Red (BGR format)
CvScalar colorAdd = cvScalar(30.0, 0, 20.0);
cvAddS(img, colorAdd, img);
// Show the image in the named window
cvShowImage( argv[1], img );
// Idle until the user hits the “Esc” key.
while( 1 ) {
if( cvWaitKey( 100 ) == 27 ) break;
}
cvDestroyWindow( argv[1] );
cvReleaseImage( &img );
exit(0);
}

尚未测试代码,希望对您有所帮助。

关于image - 从输入图像获取RGB像素并在opencv中重建输出图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6868723/

相关文章:

python - 缩小图像的宽度/高度以适应给定的纵横比。如何? - Python 图像缩略图

ios - 设置绘制到图像时文本的描边宽度

php - Base 64 编码与加载图像文件

image - 使用OpenCV去除纸张上的墨水痕迹

opencv - 在二维图像中寻找路径障碍物

python - 如何填充图像边缘的圆形轮廓?

c - OpenCV 较低的颜色值

java - 随机 HSV 颜色

c++ - 将 YUV422 转换为 RGB24

Java 位图 RGB 操作