zoukankan      html  css  js  c++  java
  • OpenCV——高斯模糊与毛玻璃特效


    // define head function
    #ifndef PS_ALGORITHM_H_INCLUDED
    #define PS_ALGORITHM_H_INCLUDED
    
    #include <iostream>
    #include <string>
    #include "cv.h"
    #include "highgui.h"
    #include "cxmat.hpp"
    #include "cxcore.hpp"
    #include "math.h"
    
    using namespace std;
    using namespace cv;
    
    void Show_Image(Mat&, const string &);
    
    #endif // PS_ALGORITHM_H_INCLUDED
    
    /*
    This program will generate
    gaussian blur and glass  effect
    
    */
    
    
    #include "PS_Algorithm.h"
    #include <time.h>
    
    using namespace std;
    using namespace cv;
    
    int main()
    {
        string Img_name("9.jpg");
        Mat Img_in;
        Img_in=imread(Img_name);
        Show_Image(Img_in, Img_name);
    
        Mat Img_out(Img_in.size(), CV_32FC3);
        Img_in.convertTo(Img_out, CV_32FC3);
    
        Mat temp;
        temp=Img_out.rowRange(100, 300);
    
        cv::GaussianBlur(temp, temp, Size(21,21), 0, 0);
        cv::GaussianBlur(temp, temp, Size(21,21), 0, 0);
    
    
        Img_out=Img_out/255.0;
        Show_Image(Img_out, "out");
    
        imwrite("Out.jpg", Img_out*255);
    
    
        waitKey();
    
    }
    
    
    // define the show image
    #include "PS_Algorithm.h"
    #include <iostream>
    #include <string>
    
    using namespace std;
    using namespace cv;
    
    void Show_Image(Mat& Image, const string& str)
    {
        namedWindow(str.c_str(),CV_WINDOW_AUTOSIZE);
        imshow(str.c_str(), Image);
    
    }
    
    

    原图 


    效果图


  • 相关阅读:
    工单系统(帮助中心)
    理解RESTful架构
    trace显示不出东西
    thinkphp
    在一个元素中查找子元素
    阻止表单元素失去焦点
    RelativeLayout不能调用measure去直接测量子元素
    兼容加载Xml字符串
    IE下载时提示无法下载,重试后成功
    借用layer让弹层不限制在iframe内部
  • 原文地址:https://www.cnblogs.com/mtcnn/p/9412582.html
Copyright © 2011-2022 走看看