• 尺度空间理论


      看到一篇博文,主要讲的是图像金字塔:http://www.cnblogs.com/ronny/p/3886013.html

      最后博主关于尺度的选择很有启发性,当我们不知道物体的尺度有多大时,可以先定义一个模板,再与金字塔的每层图像进行匹配。

      

    #include "opencv2/core/core.hpp"
    #include "opencv2/features2d/features2d.hpp"
    #include "opencv2/highgui/highgui.hpp"
    #include "opencv2/calib3d/calib3d.hpp"
    #include "opencv2/nonfree/nonfree.hpp"
    #include<opencv2/highgui/highgui.hpp>
    #include<opencv2/imgproc/imgproc.hpp>
    #include <iostream>
    using namespace cv;
    using namespace std;
    
    
    enum pyrType { PYR_GUASS, PYR_LAPLACE };
    void genPyr(const Mat& imgSrc, vector<Mat>& outPutArray, int TYPE, int level)
    {
        outPutArray.assign(level + 1, Mat());
        outPutArray[0] = imgSrc.clone(); // the 0 level is the image. 
        for (int i = 0; i != level; i++)
        {
            pyrDown(outPutArray[i], outPutArray[i + 1]);
        }
        if (PYR_GUASS == TYPE)
        {
            return;
        }
        for (int i = 0; i != level; i++)
        {
            Mat UpSampleImg;
            pyrUp(outPutArray[i + 1], UpSampleImg, outPutArray[i].size());
            outPutArray[i] -= UpSampleImg;
        }
    }
    vector<Mat> outPutArray;
    Mat g_srcImage, g_dstImage, g_tmpImage;
    int main()
    {
        g_srcImage = imread("1.jpg");
        //namedWindow("原图", WINDOW_AUTOSIZE);
        //imshow("原图", g_srcImage);
    
        g_tmpImage = g_srcImage;
        g_dstImage = g_tmpImage;
        int key = 0;
        genPyr(g_srcImage, outPutArray, 1, 2);
    
        imshow("", outPutArray[1]);
            /*key = 's';
            switch (key)
            {
            case 27:
                return 0;
                break;
            case 'a':
                //图像尺寸加倍,在每个维度上扩大为原来的两倍,新增的行(偶数行)以0填充,
                //然后给指定的滤波器卷积,去估计“丢失像素的近似值”
                pyrUp(g_tmpImage, g_dstImage, Size(g_tmpImage.cols*2 , g_tmpImage.rows*2 ));
                break;
            case 'w':
                resize(g_tmpImage, g_dstImage, Size(g_tmpImage.cols * 2, g_tmpImage.rows * 2));
                break;
            case 'd':
                //对图像进行高斯内核卷积,将所有偶数的行和列去除
                pyrDown(g_tmpImage, g_dstImage, Size(g_tmpImage.cols / 2, g_tmpImage.rows / 2));
                break;
            case 's':
                resize(g_tmpImage, g_dstImage, Size(g_tmpImage.cols /2, g_tmpImage.rows / 2));
            
            }
            imshow("目标图", g_dstImage);
        */
    
            waitKey(0);
            return 0;
    }
    View Code
  • 相关阅读:
    Linux模拟网络延迟、丢包等
    TestLink汉化操作
    onems设备管理系统(TR-069和OMA)
    Installation Guide Ubuntu 16.04
    Configure GenieACS
    Linux下的tar压缩解压缩命令详解
    genieacs Installation on Ubuntu14.04
    Pyqt中富文本编辑器
    安装MongoDB
    到底什么是贝叶斯?
  • 原文地址:https://www.cnblogs.com/573177885qq/p/4729355.html
Copyright © 2020-2023  润新知