Example 2 : Multi Sampling And Filtering Methods
来源:互联网 发布:洛瑞数据 编辑:程序博客网 时间:2024/05/17 08:45
#include<vector>#include<iostream>#include"Vector3.h"#include"rgb.h"#include"Image.h"#include"Shape.h"#include"Triangle.h"#include"Sphere.h"#include <fstream>#include "Sample.h"using namespace std;#define IMAGE_WIDTH512#define IMAGE_HEIGHT384#define NUM_SAMPLES16int main(){Image im(IMAGE_WIDTH, IMAGE_HEIGHT);int sample_type, r, c, s;Vector2* xySamples = new Vector2[NUM_SAMPLES];float x, y, total, tmp;ofstream singleFile("single.ppm");ofstream box_16File("box_16.ppm");Sample sampler;for (sample_type = 0; sample_type < 4; sample_type++){for (r = 0; r < IMAGE_HEIGHT; r++){for (c = 0; c < IMAGE_WIDTH; c++){switch (sample_type){case 0:for (s = 0; s < NUM_SAMPLES; s++){xySamples[s].setX(0);xySamples[s].setY(0);}break;case 1:// jitter 理解为: 为一个pixel, 产生NUM_SAMPLES个偏移值sampler.jitter(xySamples, NUM_SAMPLES);//sampler.multiJitter()// filter 理解为: 控制一个pixel,NUM_SAMPLES个偏移值的范围,从[0,1] -> [-0.5, 0.5]sampler.boxFilter(xySamples, NUM_SAMPLES);//sampler.cubicFilter()break;}// this is a 2D function defined for sample locations in screen space,so it is evaluated directly instead of tracing rays. total = 0;for (s = 0; s < NUM_SAMPLES; s++){x = c + xySamples[s].x();y = r + xySamples[s].y();tmp = (x*x + y*y) / 100;total += 0.5f * (1.0f + (float)sin(tmp));}// 平均一个Pixel的颜色total /= NUM_SAMPLES;im.set(r, c, rgb(total, total, total));}}if (sample_type == 0){im.writePPM(singleFile);}else{im.writePPM(box_16File);}}}
0 0
- Example 2 : Multi Sampling And Filtering Methods
- AppendChunk and GetChunk Methods Example (VC++)
- Chapter 11: Sampling Methods
- Filtering Data Example
- An Example of Perl Multi-thread 2
- Spatial Filtering and Median Filtering
- Monte Carlo Sampling Methods-- 蒙特卡洛采样方法
- Generics Tutorial – Example Class, Interface, Methods, Wildcards and much more
- Linear Filtering and Prediction
- Bridges and Frame Filtering
- 17.5.2 Static and instance methods
- 17.5.2 Static and instance methods
- Multi-Threaded Libevent Server Example
- 第11章:Sampling methods exercise 1-14
- Topic model and Gibbs Sampling
- PRML读书会第十一章 Sampling Methods(MCMC, Markov Chain Monte Carlo,Metropolis-Hastings,Gibbs Sampling)
- Properties, methods and events
- Java class and methods.
- poj 3253 Fence Repair
- Android事件分发机制完全解析(终极版二)
- 三栏网页布局
- QList类、QLinkedList类和QVector类
- opencv中的Kmeans使用示例
- Example 2 : Multi Sampling And Filtering Methods
- 设计模式笔记-Interpreter解释器模式
- 算法排序之冒泡排序与插入排序
- HBuilder配置SVN
- H.264 Quantization
- PHP中is_file,file_exists的区别,is_file 不能替代file_exits的理由
- 第十五周项目2洗牌
- Java中Properties类的使用
- 【OpenCV_12】旋转视频以及图片 Rotate Image & Video