博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
OpenCV——Perlin Noise
阅读量:4647 次
发布时间:2019-06-09

本文共 1788 字,大约阅读时间需要 5 分钟。

// define head function#ifndef PS_ALGORITHM_H_INCLUDED#define PS_ALGORITHM_H_INCLUDED#include 
#include
#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/*perlin noise.*/#include "PS_Algorithm.h"#include
using namespace std;using namespace cv;void Generate_smoothnoise(Mat& src, Mat& std, int octave);float Cosine_Interpolate(float x1,float x2,float alpha);#define pi 3.1415926int main(){ string Img_name("4.jpg"); Mat Img; Img=imread(Img_name); Mat Cloud(Img.size(), CV_32FC1); Mat Cloud_Temp(Img.size(), CV_32FC1); Mat Base_Noise(Img.size(), CV_32FC1); cv::randn(Base_Noise, 0.5, 0.25); // Show_Image(Base_Noise, "N1"); float persistance = 0.8; float totalAmplitude = 0.0; float amplitude; int octaveCount=8; for (int i=0; i
(sample_i0,sample_j0), src.at
(sample_i0,sample_j1), horizontal_blend); // blend the bottom two corners bottom = Cosine_Interpolate(src.at
(sample_i1,sample_j0), src.at
(sample_i1,sample_j1), horizontal_blend); // final blend dst.at
(i,j) = Cosine_Interpolate(top, bottom, vertical_blend); } }}float Cosine_Interpolate(float x1,float x2,float alpha){ float ft, f; float y; ft = alpha * pi; f = (1 - cos(ft)) * .5; y=x1*(1-f)+x2*f; return y;}// define the show image#include "PS_Algorithm.h"#include
#include
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);}

原图 

效果图

转载于:https://www.cnblogs.com/mtcnn/p/9412531.html

你可能感兴趣的文章
Tempdb--monitoring and troubleshooting
查看>>
java.io.IOException: Unable to open sync connection!
查看>>
词法分析
查看>>
让你提前认识软件开发(50):软件需求
查看>>
OpenCV两张图片的合并
查看>>
C#-简单的定时器(C# ConsoleApp) ---ShinePans
查看>>
公式编辑器怎样使用具体图解
查看>>
GREENPLUM简单介绍
查看>>
2018-08-20内容IO流中的File类+文件过滤器FileFilter+递归
查看>>
结构体
查看>>
内置函数
查看>>
函数定义
查看>>
R语言 for循环之break,next
查看>>
老生常谈:Windows的7类安全漏洞
查看>>
表单重复提交问题的三种解决思路
查看>>
Windows Phone开发基础(7)《101 Windows Phone 7 Apps》Weight Tracker 提供几种体重发展(折线图 趋势图)...
查看>>
Cookie seesion 赋值
查看>>
winFrom程序更新自动安装
查看>>
Mysql数据类型
查看>>
1.2 日志框架
查看>>