嗨,我想用opencv告诉我空白图像的像素值,所以输出看起来像这样
10001
00040
11110
00100
Run Code Online (Sandbox Code Playgroud)
这是我当前的代码,但我不知道如何访问CV_GET_CURRENT调用的结果..任何帮助?
IplImage readpix(IplImage* m_image) {
cout << "Image width : " << m_image->width << "\n";
cout << "Image height : " << m_image->height << "\n";
cout << "-----------------------------------------\n";
CvPixelPosition8u position;
CV_INIT_PIXEL_POS(position, (unsigned char*)(m_image->imageData), m_image->widthStep, cvSize(m_image->width, m_image->height), 0, 0, m_image->origin);
for(int y = 0; y < m_image->height; ++y) // FOR EACH ROW
{
for(int x = 0; x < m_image->width; ++x) // FOR EACH COL
{
CV_MOVE_TO(position, x, y, 1);
unsigned char colour = …Run Code Online (Sandbox Code Playgroud) 我对使用多个频道感到困惑.以下哪一项是正确的?
// roi is the image matrix
for(int i = 0; i < roi.rows; i++)
{
for(int j = 0; j < roi.cols; j+=roi.channels())
{
int b = roi.at<cv::Vec3b>(i,j)[0];
int g = roi.at<cv::Vec3b>(i,j)[1];
int r = roi.at<cv::Vec3b>(i,j)[2];
cout << r << " " << g << " " << b << endl ;
}
}
Run Code Online (Sandbox Code Playgroud)
要么,
for(int i = 0; i < roi.rows; i++)
{
for(int j = 0; j < roi.cols; j++)
{
int b = roi.at<cv::Vec3b>(i,j)[0];
int g …Run Code Online (Sandbox Code Playgroud) 我刚刚意识到,在大量搜索OpenCv中如何访问像素的强度值后,网上没有任何内容.灰度图像.
大多数在线搜索都是关于如何访问彩色图像的BGR值,如下所示:在openCV中访问某些像素RGB值
image.at <>基本上是3个通道,即BGR,出于好奇,是否有另一种类似的方法来自OpenCV访问灰度图像的某个像素值?