积分图
来源:互联网 发布:冬季牛仔裤淘宝网男装 编辑:程序博客网 时间:2024/09/21 09:22
How it works
Suppose an image is
All other pixels have a value equal to the sum
See the integral in the above image? Every pixel is the summation of the pixels before it (above and to the left).
Now, to calculate the summation of the pixels in the black box, you take the corresponding box in the integral. You sum as follows: (Bottom right + top left – top right – bottom left).
So for the 3,5,4,1 box, the calculations would go like this: (30+0-17-0 = 13). For the 4,1 box, it would be (0+15-10-0 = 5).
This way, you can calculate summations in rectangular regions rapidly.
More than just summations!
With the basic idea in mind, you can extend it to more types of summations. You can calculate the sum of squares. You can rotate the image by 45 degrees and then do the summations. Then, you can calculate the totals in any arbitrary rectangular region that is upright or tilted at 45 degrees.
You can calculate summations on irregular areas too (only those with 90 degree corners though). Not just that, you can do super fast blurs, approximate gradients and compute means and standard deviations very fast.
Calculating Integral Images in OpenCV
OpenCV comes with a predefined function to calculate an integral image.
void cvIntegral(const CvArr* image, CvArr* sum, CvArr* sqsum=NULL, CvArr* tilted_sum=NULL);
The parameters are, as always, self explanatory:
image: the source image
sum: the sum summation integral image
sqsum: the square sum integral image
tiled_sum:
image is rotated by 45 degrees and then its integral is calculated
Summary
Calculating integral images is trivial. But they let you do more complex stuff (like blurring, HAAR wavelets, etc) super fast. And
也贴出只针对8位灰度图的代码,相当精简,看起来会比openCV的稍稍舒服一些
for( y = 0; y < image->height; y++, src += image->width, sum += sum_width )
{
s = sum[-1] = 0; int
( x = 0; x < image->width; x ++ ) for
{
s += src[x];
sum[x] = sum[x - sum_width] + s;
}
}
转载 http://blog.sina.com.cn/s/blog_5584da9601018f5x.html
- 积分图
- 积分图
- 积分图
- 积分图
- 积分图
- 积分图
- 积分图
- 积分图
- 【计算机视觉】积分图和积分直方图
- 电工积分图
- openCV计算积分图
- ComputerVision:积分图求解
- opencv积分图计算
- 快速计算积分图
- 计算积分图
- 快速计算积分图
- 积分图 源码
- Adaboost-积分图计算
- Action访问web内置对象
- Qt painter drawPolyline in paintEvent
- FOR XML PATH 的使用
- oracle周数计算方法
- Electronic Communication Network - ECN
- 积分图
- 体验下Xcode5与ios7
- 利用动软代码生成器 自动生成LINQ需要用的数据实体类
- 解决MWPhotoBrowser中spinner不停的转不消失的问题
- 通过进程Id获取窗口句柄
- java移位操作
- 关于Starling的一些链接
- 【iOS开发】---- 手把手教你github托管代码
- Gtk-WARNING **: cannot open display: :0.0