roc*_*esh 1 c++ opencv image-processing computer-vision
为了使我的问题更清楚,请查看代码.
vector<cv::Vec3b> v_char; // the vector that I am storing my r,g,b values, or b,g,r in this case since it's opencv.
Run Code Online (Sandbox Code Playgroud)
我知道打印出使用值的价值,我可以直接从图像中取出,就像这样.
b = image.at<cv::Vec3b>(i,j)[0];
g = image.at<cv::Vec3b>(i,j)[1];
r = image.at<cv::Vec3b>(i,j)[2];
Run Code Online (Sandbox Code Playgroud)
但是,没有使用图像(想象图像消失了),我只想要来自矢量的值,v_char所有的图像值都已存储,比如说,我只想要r值,我该怎么办找回来的?尝试在互联网上搜索并玩弄代码,但无济于事:(
编辑:更多细节向量,v_char只是存储图像的一行的值.例如:我想找到并打印出可以在v_char向量中找到的特定行的所有r值.我可以使用for循环,但是如何仅声明r值?
Vec3b v_char本身是可以作为被访问的3个值的矢量first values = v_char.val[0],second values = v_char.val[1],third values = v_char.val[2].由于您只需要red值,因此只需访问v_char.val[0]整个向量中的所有值 .
所以通过for loop尝试获得所有的价值:
v_char[i].val[0]; // "i" represents the index of "for loop" for a given row
Run Code Online (Sandbox Code Playgroud)