MRaster examples 21.0.0.0
Image Processing Library
Loading...
Searching...
No Matches
circles.cpp
Go to the documentation of this file.
1// -*- Mode:C++; Coding:us-ascii-unix; fill-column:158 -*-
2/*******************************************************************************************************************************************************.H.S.**/
3/**
4 @file circles.cpp
5 @author Mitch Richling <https://www.mitchr.me>
6 @brief Mathematical art with circles.@EOL
7 @see https://www.mitchr.me/SS/circles2/index.html
8 @copyright
9 @parblock
10 Copyright (c) 1988-2015, Mitchell Jay Richling <https://www.mitchr.me> All rights reserved.
11
12 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
13
14 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation
17 and/or other materials provided with the distribution.
18
19 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software
20 without specific prior written permission.
21
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
27 DAMAGE.
28 @endparblock
29 @filedetails
30
31*/
32/*******************************************************************************************************************************************************.H.E.**/
33/** @cond exj */
34
35//--------------------------------------------------------------------------------------------------------------------------------------------------------------
36#include "ramCanvas.hpp"
37
38//--------------------------------------------------------------------------------------------------------------------------------------------------------------
39int main(void) {
40 std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
41 const int n = 120000;
42 const std::string v = "015";
43 const int width = 1920*2;
44 const int height = 1080*2;
45 const double aspect = 1.0*width/height;
46 mjr::ramCanvas3c8b theRamCanvas(width*1, height*1, -1.2*aspect, 1.2*aspect, -1.2, 1.2);
47
48 theRamCanvas.setDrawMode(mjr::ramCanvasRGB8b::drawModeType::ADDCLAMP);
49
50 for(int k=0; k<n; k++) {
51
52 // // v="001" n=120000 (frog)
53 // double x = (cos(11.0*std::numbers::pi*k/n))*(1.0-3.0/4.0*std::pow(cos(10.0*std::numbers::pi*k/n), 2));
54 // double y = -((sin(17.0*std::numbers::pi*k/n))*(1.0-3.0/4.0*pow(cos(12.0*std::numbers::pi*k/n), 2)));
55 // double s = 1.0/80.0+1.0/10.0*pow(sin(56.0*std::numbers::pi*k/n), 2);
56 // double r = 255.0*(0.5+pow(sin(56.0*std::numbers::pi*k/n), 4))/100.0;
57 // double g = 255.0*(0.5+pow(cos(42.0*std::numbers::pi*k/n), 2))/80.0;
58 // double b = 255.0*(0.5+pow(sin(56.0*std::numbers::pi*k/n), 4))/125.0;
59
60 // // v="002" n=20000
61 // double x = (sin(33.0*std::numbers::pi*k/n) * (cos(19.0*std::numbers::pi*k/n)))*2;
62 // double y = (sin(20.0*std::numbers::pi*k/n) * (cos(33.0*std::numbers::pi*k/n)))*2;
63 // double s = std::pow(sin(43.0*std::numbers::pi*k/n), 3)*0.75+0.5;
64 // double r = 255.0*(0.5+pow(sin(26.0*std::numbers::pi*k/n), 4))/10.0;
65 // double g = 255.0*(0.5+pow(cos(46.0*std::numbers::pi*k/n), 2))/17.0;
66 // double b = 255.0*(0.5+pow(sin(56.0*std::numbers::pi*k/n), 4))/17.0;
67
68 // // v="003" n=40000
69 // double x = (sin(33.0*std::numbers::pi*k/n) * (cos(19.0*std::numbers::pi*k/n)))*1;
70 // double y = (sin(20.0*std::numbers::pi*k/n) * (cos(33.0*std::numbers::pi*k/n)))*1;
71 // double s = std::pow(sin(143.0*std::numbers::pi*k/n), 3)*.05+0.0;
72 // double r = 255.0*(0.5+pow(sin(26.0*std::numbers::pi*k/n), 4))/10.0;
73 // double g = 255.0*(0.5+pow(cos(46.0*std::numbers::pi*k/n), 2))/17.0;
74 // double b = 255.0*(0.5+pow(sin(56.0*std::numbers::pi*k/n), 4))/17.0;
75
76 // // v="004" n=40000
77 // double x = (sin(33.0*std::numbers::pi*k/n) * (cos(19.0*std::numbers::pi*k/n)))*2;
78 // double y = (sin(20.0*std::numbers::pi*k/n) * (cos(33.0*std::numbers::pi*k/n)))*1.2;
79 // double s = std::pow(sin(33.0*std::numbers::pi*k/n), 3)*.15+0.0;
80 // double r = 255.0*(0.5+pow(sin(26.0*std::numbers::pi*k/n), 4))/10.0;
81 // double g = 255.0*(0.5+pow(cos(46.0*std::numbers::pi*k/n), 2))/17.0;
82 // double b = 255.0*(0.5+pow(sin(56.0*std::numbers::pi*k/n), 4))/17.0;
83
84 // // v="005" n=40000
85 // double x = (sin(33.0*std::numbers::pi*k/n) * (cos(19.0*std::numbers::pi*k/n)))*2.3;
86 // double y = (sin(20.0*std::numbers::pi*k/n) * (cos(33.0*std::numbers::pi*k/n)))*2;
87 // double s = std::pow(sin(33.0*std::numbers::pi*k/n), 3)*.55+0.4;
88 // double r = 255.0*(0.5+pow(sin(26.0*std::numbers::pi*k/n), 4))/10.0;
89 // double g = 255.0*(0.5+pow(cos(46.0*std::numbers::pi*k/n), 2))/17.0;
90 // double b = 255.0*(0.5+pow(sin(56.0*std::numbers::pi*k/n), 4))/17.0;
91
92 // // v="006" n=10000
93 // double x = (sin(133.0*std::numbers::pi*k/n) * (cos(19.0*std::numbers::pi*k/n)))*1;
94 // double y = (sin(20.0*std::numbers::pi*k/n) * (cos(133.0*std::numbers::pi*k/n)))*1;
95 // double s = std::pow(sin(33.0*std::numbers::pi*k/n), 3)*1.25+0.5;
96 // double r = 255.0*(0.5+pow(sin(26.0*std::numbers::pi*k/n), 4))/10.0;
97 // double g = 255.0*(0.5+pow(cos(46.0*std::numbers::pi*k/n), 2))/17.0;
98 // double b = 255.0*(0.5+pow(sin(56.0*std::numbers::pi*k/n), 4))/17.0;
99
100 // // v="007" n=10000
101 // double x = (sin(133.0*std::numbers::pi*k/n) * (cos(19.0*std::numbers::pi*k/n)))*1.2;
102 // double y = (sin(20.0*std::numbers::pi*k/n) * (cos(133.0*std::numbers::pi*k/n)))*.51;
103 // double s = std::pow(sin(133.0*std::numbers::pi*k/n), 3)*1.25+0.5;
104 // double r = 255.0*(0.5+pow(sin(26.0*std::numbers::pi*k/n), 4))/10.0;
105 // double g = 255.0*(0.5+pow(cos(46.0*std::numbers::pi*k/n), 2))/17.0;
106 // double b = 255.0*(0.5+pow(sin(56.0*std::numbers::pi*k/n), 4))/17.0;
107
108 // // v="008" n=30000
109 // double x = (sin(53.0*std::numbers::pi*k/n) * (1-cos(33.0*std::numbers::pi*k/n)))*1;
110 // double y = (sin(33.0*std::numbers::pi*k/n) * (1+cos(33.0*std::numbers::pi*k/n)))*0.8;
111 // double s = std::pow(sin(122.0*std::numbers::pi*k/n), 3)*0.0 + 0.1;
112 // double r = 255.0*(0.5+pow(sin(56.0*std::numbers::pi*k/n), 4))/17.0;
113 // double g = 255.0*(0.5+pow(cos(46.0*std::numbers::pi*k/n), 2))/17.0;
114 // double b = 255.0*(0.5+pow(sin(56.0*std::numbers::pi*k/n), 4))/17.0;
115
116 // // v="009" n=100000
117 // double x = (cos(1.0*std::numbers::pi*k/n) * (sin(9.0*std::numbers::pi*k/n)))*1.;
118 // double y = (sin(8.0*std::numbers::pi*k/n) * (cos(1.0*std::numbers::pi*k/n)))*1.;
119 // double s = std::abs(sin(1.0*std::numbers::pi*k/n) * (cos(69.0*std::numbers::pi*k/n)))*1.22 + 1.1;
120 // double r = 255.0*(0.5+pow(sin(6.0*std::numbers::pi*k/n), 4))/90.0;
121 // double g = 255.0*(0.5+pow(cos(6.0*std::numbers::pi*k/n), 2))/87.0;
122 // double b = 255.0*(0.5+pow(sin(6.0*std::numbers::pi*k/n), 2))/87.0;
123
124 // // v="010" n=120000
125 // double x = (cos(11.0*std::numbers::pi*k/n))*(1.0-3.0/4.0*std::pow(cos(10.0*std::numbers::pi*k/n), 2))*2.6;
126 // double y = -((sin(17.0*std::numbers::pi*k/n))*(1.0-3.0/4.0*pow(cos(12.0*std::numbers::pi*k/n), 2)))*2.5+.3;
127 // double s = 1.0/80.0+1.0/10.0*pow(sin(56.0*std::numbers::pi*k/n), 2) + .5;
128 // double r = 255.0*(0.5+pow(sin(56.0*std::numbers::pi*k/n), 4))/7.0/54.0;
129 // double g = 255.0*(0.5+pow(cos(42.0*std::numbers::pi*k/n), 2))/7.0/38.0;
130 // double b = 255.0*(0.5+pow(sin(56.0*std::numbers::pi*k/n), 4))/7.0/48.0;
131
132 // // v="011" n=120000
133 // double x = (cos(1.0*std::numbers::pi*k*k/n) * (sin(9.0*std::numbers::pi*k/n)))*1.;
134 // double y = (sin(8.0*std::numbers::pi*k/n) * (cos(1.0*std::numbers::pi*k*k/n)))*1.;
135 // double s = std::abs(sin(1.0*std::numbers::pi*k/n) * (cos(29.0*std::numbers::pi*k/n)))*.92 + 1.1;
136 // double r = 255.0*(0.5+pow(sin(6.0*std::numbers::pi*k/n), 4))/90.0;
137 // double g = 255.0*(0.5+pow(cos(6.0*std::numbers::pi*k/n), 2))/97.0;
138 // double b = 255.0*(0.5+pow(sin(6.0*std::numbers::pi*k/n), 2))/97.0;
139
140 // // v="012" n=120000
141 // double x = (cos(1.0*std::numbers::pi*k*k/n) * (sin(9.0*std::numbers::pi*k/n)))*2.0;
142 // double y = (sin(8.0*std::numbers::pi*k/n) * (cos(1.0*std::numbers::pi*k*k/n)))*1.;
143 // double s = std::abs(sin(1.0*std::numbers::pi*k*k/n) * (cos(2.0*std::numbers::pi*k/n)))*.92 + .1;
144 // double r = 255.0*(0.5+pow(sin(16.0*std::numbers::pi*k/n), 4))/90.0;
145 // double g = 255.0*(0.5+pow(cos(6.0*std::numbers::pi*k/n), 2))/100.0;
146 // double b = 255.0*(0.5+pow(sin(6.0*std::numbers::pi*k/n), 2))/100.0;
147
148 // // v="013" n=120000
149 // double x = (cos(11.0*std::numbers::pi*k/n) * (sin(9.0*std::numbers::pi*k/n)))*2.0;
150 // double y = (sin(8.0*std::numbers::pi*k/n) * (cos(11.0*std::numbers::pi*k/n)))*1.;
151 // double s = std::abs(sin(9.0*std::numbers::pi*k/n) * (cos(11.0*std::numbers::pi*k/n)))*.4 + .51;
152 // double r = 255.0*(0.5+pow(sin(26.0*std::numbers::pi*k/n), 4))/200.0;
153 // double g = 255.0*(0.5+pow(cos(6.0*std::numbers::pi*k/n), 2))/220.0;
154 // double b = 255.0*(0.5+pow(sin(6.0*std::numbers::pi*k/n), 2))/220.0;
155
156 // // v="014" n=120000
157 // double x = (cos(11.0*std::numbers::pi*k/n) * (sin(9.0*std::numbers::pi*k/n)))*2.5;
158 // double y = (sin(8.0*std::numbers::pi*k/n) * (cos(11.0*std::numbers::pi*k/n)))*1.5;
159 // double s = std::abs(sin(9.0*std::numbers::pi*k/n) * (cos(11.0*std::numbers::pi*k*k/n)))*.4 + .51;
160 // double r = 255.0*(0.5+pow(sin(26.0*std::numbers::pi*k/n), 4))/200.0;
161 // double g = 255.0*(0.5+pow(cos(6.0*std::numbers::pi*k/n), 2))/220.0;
162 // double b = 255.0*(0.5+pow(sin(6.0*std::numbers::pi*k/n), 2))/220.0;
163
164 // v="015" n=120000
165 double x = (cos(11.0*std::numbers::pi*k/n))*(1.0-3.0/4.0*std::pow(cos(10.0*std::numbers::pi*k/n), 2));
166 double y = -((sin(17.0*std::numbers::pi*k/n))*(1.0-3.0/4.0*pow(cos(12.0*std::numbers::pi*k/n), 2)));
167 double s = 1.0/80.0+1.0/10.0*pow(sin(56.0*std::numbers::pi*k/n), 2) + .5;
168 double r = 255.0*(0.5+pow(sin(56.0*std::numbers::pi*k/n), 4))/7.0/54.0;
169 double g = 255.0*(0.5+pow(cos(42.0*std::numbers::pi*k/n), 2))/7.0/38.0;
170 double b = 255.0*(0.5+pow(sin(56.0*std::numbers::pi*k/n), 4))/7.0/48.0;
171
172 mjr::ramCanvasRGB8b::colorChanType ri = static_cast<mjr::ramCanvasRGB8b::colorChanType>(r);
173 mjr::ramCanvasRGB8b::colorChanType gi = static_cast<mjr::ramCanvasRGB8b::colorChanType>(g);
174 mjr::ramCanvasRGB8b::colorChanType bi = static_cast<mjr::ramCanvasRGB8b::colorChanType>(b);
175
176 theRamCanvas.drawCircle(x, y, s, mjr::ramCanvasRGB8b::colorType(ri, gi, bi));
177 }
178
179 double kernel[51*51];
180 int kSize = 51;
181 theRamCanvas.computeConvolutionMatrixGausian(kernel, kSize, 20);
182 theRamCanvas.convolution(kernel, kSize);
183
184 theRamCanvas.autoHistStrech();
185
186 theRamCanvas.writeTIFFfile("circles_" + v + "b.tiff");
187
188 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
189 std::cout << "Total Runtime " << runTime.count() << " sec" << std::endl;
190}
191/** @endcond */
int main(int argc, char *argv[])