3 using namespace Psychlops;
5 void psychlops_main() {
6 Canvas cnvs(1024,700,Canvas::window);
13 Color::setGammaValue(1.0,1.0,1.0);
16 Image buf[10], reference[10], difference[10], difference2[10];
18 Figures::ShaderGrating grat;
\r
19 Figures::ShaderExponentialDot dot;
\r
20 Figures::ShaderGabor gabor;
\r
21 //std::ofstream f("shader_prec_test.txt");
\r
24 double c=1, w=48, o=-40, p=0;
25 Widgets::Dial dial[4];
31 //for(double o=0; o<PI; o+=PI/8) {
\r
32 //for(double w=4; w<128; w*=2) {
\r
33 //for(double c=0.25; c<=1.0; c+=0.25) {
39 gabor.phase = p/360.0*2*PI;
40 gabor.orientation = o/360.0*2*PI;
46 grat.phase = p/360.0*2*PI;
47 grat.orientation = o/360.0*2*PI;
55 Figures::drawGaborToImage(reference[0], 30, 1.0/w, c, o/360.0*2*PI, p/360.0*2*PI);
56 Figures::drawGratingToImage(reference[1], 240,240 , 1.0/w, c, o/360.0*2*PI, p/360.0*2*PI);
57 // Figures::drawExponentialToImage(reference[2], 30, 1);
59 cnvs.clear(Color(0.25));
60 cnvs.msg(L"シェーダ - CPU = 誤差(赤:誤差2以上)", 100, 40, Color::white);
61 for(int i=0; i<2; i++) {
\r
62 //f << c << "\t" << w << "\t" << o/2.0/PI*360.0 << "\t";
64 Figures::substructImages(difference[i], buf[i], reference[i], 255.0)
67 buf[i].centering(170,170+i*300).draw();
68 reference[i].centering(470,170+i*300).draw();
69 difference[i].centering(770,170+i*300).draw();
74 const int DIFF = 2, SLINE = 120;
75 difference2[DIFF].set(480,512);
77 for(int y=0; y<240; y++) {
78 y1 = (int)(512-reference[DIFF].getPix(SLINE,y).getR()*512);
79 y2 = (int)(512-buf[DIFF].getPix(SLINE,y).getR()*512);
80 difference2[DIFF].rect(Psychlops::Rectangle(y*2, y1, y*2+1, 511), Color(0.4));
81 if(y1>y2) difference2[DIFF].rect(Psychlops::Rectangle(y*2, y2, y*2+1, y1), Color::green);
82 if(y1<y2) difference2[DIFF].rect(Psychlops::Rectangle(y*2, y1, y*2+1, y2), Color::red);
84 difference2[DIFF].centering().draw();
88 // if(Keyboard::esc.pushed()) { exit(0); }
\r
94 while(!Keyboard::esc.pushed()) {
95 cnvs.clear(Color(0.25));
96 cnvs.msg(L"シェーダ - CPU = 誤差(赤:誤差2以上)", 200, 40, Color::white);
97 for(int i=0; i<2; i++) {
98 buf[i].centering(270,170+i*300).draw();
99 reference[i].centering(570,170+i*300).draw();
100 difference[i].centering(870,170+i*300).draw();
102 for(int i=0; i<4; i++) dial[i].set(50).centering(50,100+i*50).draw();
103 if(dial[0].changed() || dial[1].changed() || dial[2].changed() || dial[3].changed()) goto REDRAW;
104 cnvs.msg(L"ピクセルの位相に鋭敏 コントラストに不変 → π(無理数)の有効桁数の問題", 200, 640, Color::white);
105 cnvs.msg(L"コントラストに鋭敏 → 8 bit変換時の丸めがISO丸めか四捨五入か", 200, 680, Color::white);