简体   繁体   English

OPENCV:计算图像左边缘的像素

[英]OPENCV : count pixel from the left edge of the image

i want to know how to make a loop to count image pixel start counting pixels from the left edge of the image 我想知道如何制作循环来计算图像像素开始计算图像左边缘的像素

how to make this using c++ opencv 如何使用c ++ opencv进行此操作

you don't need to build the loop yourself, it is all already done for you. 你不需要自己构建循环,它已经为你完成了。

cv::Mat img = cv::imread("img.jpg");
std::cout << img.total() << std::endl;

The first line loads your image into the standard C++ OpenCV container Mat . 第一行将您的图像加载到标准C ++ OpenCV容器Mat The second line prints the number of elements in the underlaying array of the Mat , in case of an image, this is equal to the total number of pixels of that image. 第二行打印Mat的底层数组中的元素数,如果是图像,则等于该图像的总像素数。

If those constructs were new to you, you should start with reading these tutorials. 如果这些构造对您来说是新的,那么您应该从阅读这些教程开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM