图像处理中有一种常见的操作——缩放。
最常见的是放大(zoom in)和缩小(zoom out),以及图像金字塔。有时需要对两张不同尺度的图像上匹配一个物体,由于分辨率不一样,需要将图像转换到不同的尺度空间,在不同的尺度空间中寻找特征,在进行后续处理。一次,不同尺度空间的图像金字塔式很有用的。
图像金字塔包括:
高斯金字塔——用来对图像进行降采样。
拉普拉斯金字塔——根据他的上层降采样图片来重建上层图片。
高斯金字塔是从底层向上,逐层降采样得到,尺度从底向上越来越小;降采样之后图像大小是源图像MXN的M/2,N/2,就是对源图像删除偶数行和列,即得到降采样之后上一层的图片。
高斯金字塔的生成过程有两步:
对当前层进行高斯模糊。
删除当前层的偶数行与列。即可得到上一层的图像,这样上一层和下一层相比,都只有他的1/4.
1、高斯差分(Difference of Gaussian-DOG)
定义:把同一张图像在不同参数下做高斯模糊,并将不同模糊层度的图像相减,得到的输出图像,称为高斯差分(DOG)。
高斯差分是图像的内在特征,在灰度图像增强、角点检测中经常会用到。
另外还有拉普拉斯差分。
2、相关的API:
上采样:(cv::pyrUp)——zoom in放大
/* @param src input image. @param dst output image. It has the specified size and the same type as src . @param dstsize size of the output image. @param borderType Pixel extrapolation method, see #BorderTypes (only #BORDER_DEFAULT is supported) */ CV_EXPORTS_W void pyrUp( InputArray src, OutputArray dst, const Size& dstsize = Size(), int borderType = BORDER_DEFAULT );下采样(cv::pyrDown)——zoom out缩小
/* @param src input image. @param dst output image; it has the specified size and the same type as src. @param dstsize size of the output image. @param borderType Pixel extrapolation method, see #BorderTypes (#BORDER_CONSTANT isn't supported) */ CV_EXPORTS_W void pyrDown( InputArray src, OutputArray dst, const Size& dstsize = Size(), int borderType = BORDER_DEFAULT );