【问题标题】:How to extract r g b color components in an image using c++如何使用 C++ 提取图像中的 r g b 颜色分量
【发布时间】:2015-02-03 05:55:09
【问题描述】:

我正在做一个关于图像加密和解密的项目。所以我需要在彩色图像中提取 RGB 颜色分量。请使用 c++ 清除我对 open cv 的疑问。提前致谢。 迪帕克·奇拉多尼

【问题讨论】:

标签: opencv


【解决方案1】:

首先将图像加载为

 Mat img=imread(file_name);

它以 BGR 格式返回 img。 现在使用以下代码 sn-p 访问 BGR 图像中的颜色分量。这里y行索引和x列索引

Vec3b intensity = img.at<Vec3b>(y, x);
uchar blue = intensity.val[0];
uchar green = intensity.val[1];
uchar red = intensity.val[2];

参考:http://docs.opencv.org/doc/user_guide/ug_mat.html

【讨论】:

    猜你喜欢
    • 2011-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-24
    • 2011-05-18
    • 2020-04-25
    • 2017-06-25
    相关资源
    最近更新 更多