圖像金字塔所用函數(shù)為:
- PyrDown
- 圖像的下采樣
- void cvPyrDown( const CvArr* src, CvArr* dst, int filter=CV_GAUSSIAN_5x5 );
- src
- 輸入圖像.
- dst
- 輸出圖像, 寬度和高度應(yīng)是輸入圖像的一半 ,傳入前必須已經(jīng)完成初始化
- filter
- 卷積濾波器的類型,目前僅支持 CV_GAUSSIAN_5x5
- 函數(shù) cvPyrDown 使用 Gaussian 金字塔分解對輸入圖像向下采樣,。首先它對輸入圖像用指定濾波器進行卷積,然后通過拒絕偶數(shù)的行與列來下采樣圖像,。
- [編輯]
- PyrUp
- 圖像的上采樣
- void cvPyrUp( const CvArr* src, CvArr* dst, int filter=CV_GAUSSIAN_5x5 );
- src
- 輸入圖像.
- dst
- 輸出圖像, 寬度和高度應(yīng)是輸入圖像的2倍
- filter
- 卷積濾波器的類型,,目前僅支持 CV_GAUSSIAN_5x5
- 函數(shù) cvPyrUp 使用Gaussian 金字塔分解對輸入圖像向上采樣。首先通過在圖像中插入 0 偶數(shù)行和偶數(shù)列,,然后對得到的圖像用指定的濾波器進行高斯卷積,,其中濾波器乘以4做插值。所以輸出圖像是輸入圖像的 4 倍大小,。(hunnish: 原理不清楚,,尚待探討)
實現(xiàn)例題為:
- #include "StdAfx.h"
- #include "highgui.h"
- #include"cv.h"
-
- //superdont
- //blog.csdn.net/superdont
- int main(int argc,char ** argv)
- {
- IplImage * src = cvLoadImage("guagua.bmp");
- IplImage * result1 = cvCreateImage(
- cvSize( src->width/2, src->height/2 ),
- src->depth,
- src->nChannels
- );
- cvPyrDown( src, result1,CV_GAUSSIAN_5x5);
- IplImage * result2 = cvCreateImage(
- cvSize( src->width*2, src->height*2 ),
- src->depth,
- src->nChannels
- );
- cvPyrUp( src, result2,CV_GAUSSIAN_5x5);
- cvNamedWindow("source",1);
- cvShowImage("source",src);
- cvNamedWindow( "PyrDown" ,1);
- cvShowImage( "PyrDown", result1);
- cvNamedWindow( "PyrUp" ,1);
- cvShowImage( "PyrUp",result2);
- cvWaitKey(0);
- cvReleaseImage(&src);
- cvReleaseImage(&result1);
- cvReleaseImage(&result2);
- cvDestroyAllWindows();
- return 0;
- }
運行結(jié)果為:
參考文獻:
1.學習OpenCV,于仕祺,,劉瑞禎,,清華大學出版社,pp.150-155
2.http://blog.csdn.net/cartoonface/article/details/5993969
3.http://www./index.php/Cv%E5%9B%BE%E5%83%8F%E5%A4%84%E7%90%86#PyrDown
|