本文介绍了OpenCV的:访问并采取平方根像素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用了OpenCV的物体检测,我想能够执行的操作之一是每个像素的平方根。我想象中的循环会是这样的:
I'm using OpenCV for object detection and one of the operations I would like to be able to perform is a per-pixel square root. I imagine the loop would be something like:
IplImage* img_;
...
for (int y = 0; y < img_->height; y++) {
for(int x = 0; x < img_->width; x++) {
// Take pixel square root here
}
}
我的问题是我怎么能在IplImage结构访问对象在坐标(x,y)的像素值?
My question is how can I access the pixel value at coordinates (x, y) in an IplImage object?
推荐答案
假设IMG_是类型的IplImage的,并假设16位无符号整型数据,我想说
Assuming img_ is of type IplImage, and assuming 16 bit unsigned integer data, I would say
unsigned short pixel_value = ((unsigned short *)&(img_->imageData[img_->widthStep * y]))[x];
又见的IplImage定义。
See also here for IplImage definition.
这篇关于OpenCV的:访问并采取平方根像素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!