OpenCV笔记-图像处理之图像金字塔

高斯金字塔和拉普拉斯金字塔。

示例代码:

#include <cv.h>

#include <highgui.h>

#include <stdio.h>



/*

*    高斯金字塔用来向下降采样图像,拉普拉斯金字塔用来从金字塔底层图像中采样    重建图像

*/



int main()

{

    IplImage* image = cvLoadImage("E:\\Res\\Hydrangeas.jpg");



    cvNamedWindow("原图像");

    cvNamedWindow("高斯金字塔图像");

    cvNamedWindow("拉普拉斯金字塔图像");

    CvSize size = cvGetSize(image);

    IplImage* out = cvCreateImage(cvSize(size.width / 2, size.height / 2), image->depth, image->nChannels);

    cvPyrDown(image, out, CV_GAUSSIAN_5x5);



    IplImage* out2 = cvCreateImage(cvSize(size.width, size.height), image->depth, image->nChannels);

    cvPyrUp(out, out2, CV_GAUSSIAN_5x5);





    cvShowImage("原图像", image);

    cvShowImage("高斯金字塔图像", out);

    cvShowImage("拉普拉斯金字塔图像", out2);



    cvWaitKey(0);



    cvDestroyAllWindows();

    cvReleaseImage(&out);

    cvReleaseImage(&out2);

    cvReleaseImage(&image);

    return 0;

}

 

你可能感兴趣的:(opencv)