MRaster examples 22.0.0.0
Image Processing Library
Loading...
Searching...
No Matches
mandeldragon_orbits.cpp
Go to the documentation of this file.
1// -*- Mode:C++; Coding:us-ascii-unix; fill-column:158 -*-
2/*******************************************************************************************************************************************************.H.S.**/
3/**
4 @file mandeldragon_orbits.cpp
5 @author Mitch Richling <https://www.mitchr.me>
6 @brief Mandeldragon orbits.@EOL
7 @std C++20
8 @copyright
9 @parblock
10 Copyright (c) 1988-2015,2025, 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 Explores the orbits of the iteration
32
33 - mandeldragon_orbits_XRANGE_omax.tiff Maximum iteration count for all orbits that hit the pixel
34 - mandeldragon_orbits_XRANGE_ohst.tiff Point histogram of exterior point orbits
35 - mandeldragon_orbits_XRANGE_ihst.tiff Point histogram of interior point orbits
36 - mandeldragon_orbits_XRANGE_color_METHOD.tiff Colorized using a combination of the above images
37 - mandeldragon_orbits_XRANGE_ohst_METHOD.tiff Colorized version of ohst
38
39The color images may be created on the command line from the monochrome, data images. For example, we can combine
40images like this:
41
42 magick \‍( mandeldragon_orbits_omax.tiff -evaluate Pow 0.8 \‍) \‍( mandeldragon_orbits_ohst.tiff -evaluate Pow 0.3 \‍) \‍( mandeldragon_orbits_ihst.tiff -evaluate Pow 0.8 \‍) -combine mandeldragon_orbits_838.png
43
44We can colorize a single monochrome image with a color scheme like this:
45
46 magick \‍( mandeldragon_orbits_ohst.tiff -evaluate Pow 0.5 \‍) ../docs/pics/cs/color_lut_docs_csPLYinferno_50.png -clut mandeldragon_orbits_csPLYinferno.png
47
48*/
49/*******************************************************************************************************************************************************.H.E.**/
50/** @cond exj */
51
52//--------------------------------------------------------------------------------------------------------------------------------------------------------------
53#include "ramCanvas.hpp"
54
55//--------------------------------------------------------------------------------------------------------------------------------------------------------------
56typedef mjr::ramCanvas1c16b rcct;
57typedef mjr::ramCanvas3c8b rcrt;
58
59//--------------------------------------------------------------------------------------------------------------------------------------------------------------
60int main(void) {
61 std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
62 const int csize = 7680/6;
63 const int maxitr = 256*4;
64 const int resMul = 16;
65 const int sweepYres = csize*resMul;
66 const double sweepYmin = -4.0;
67 const double sweepYmax = 4.0;
68 const double sweepYdel = (sweepYmax-sweepYmin)/sweepYres;
69 const std::vector<double> sweepXminL { -4.0, -4.0, -4.0};
70 const std::vector<double> sweepXmaxL { 0.0, 4.0, 4.0};
71 const std::vector<int> sweepXresL { 1, 2, 1};
72 const std::vector<std::string> caseNamesL { "neg", "all", "pos"};
73
74 for(int side=0; side<3; side++) {
75 int sweepXres = csize*resMul*sweepXresL[side];
76 double sweepXmin = sweepXminL[side];
77 double sweepXmax = sweepXmaxL[side];
78 double sweepXdel = (sweepXmax-sweepXmin)/sweepXres;;
79
80 rcct ihstRamCanvas(csize, csize, -0.6, 1.0, -0.9, 0.9);
81 rcct ohstRamCanvas(csize, csize, -0.6, 1.0, -0.9, 0.9);
82 rcct omaxRamCanvas(csize, csize, -0.6, 1.0, -0.9, 0.9);
83 std::complex<double>* theOrbit = new std::complex<rcct::coordFltType>[maxitr+1];
84
85 for(int y=0;y<sweepYres;y++) {
86 if((y%(sweepYres/16))==0)
87 std::cout << "LINE: " << y << "/" << sweepYres << std::endl;
88 for(int x=0;x<sweepXres;x++) {
89 std::complex<rcct::coordFltType> c(x * sweepXdel + sweepXmin, y * sweepYdel + sweepYmin);
90 std::complex<rcct::coordFltType> z(0.5, 0.0);
91 for(rcct::colorChanType count=0; ; count++) {
92 z = (c + 1.0) * z * (1.0 - z);
93 theOrbit[count] = z;
94 if(std::abs(z)>5.0) {
95 for(rcct::colorChanType i=10; i<=count; i++) {
96 ohstRamCanvas.incPxChan(theOrbit[i]);
97 omaxRamCanvas.tformPixel(theOrbit[i], [i](auto& c) { c.tfrmMax(i); });
98 }
99 break;
100 } else if(count>=(maxitr-1)) {
101 for(rcct::colorChanType i=10; i<=count; i++) {
102 ihstRamCanvas.incPxChan(theOrbit[i]);
103 }
104 break;
105 }
106 }
107 }
108 }
109
110 // Dump out our "data" images
111 omaxRamCanvas.autoHistStrech();
112 omaxRamCanvas.rotate90CCW();
113 omaxRamCanvas.writeTIFFfile("mandeldragon_orbits_" + caseNamesL[side] + "_omax.tiff");
114 ohstRamCanvas.autoHistStrech();
115 ohstRamCanvas.rotate90CCW();
116 ohstRamCanvas.writeTIFFfile("mandeldragon_orbits_" + caseNamesL[side] + "_ohst.tiff");
117 ihstRamCanvas.autoHistStrech();
118 ihstRamCanvas.rotate90CCW();
119 ihstRamCanvas.writeTIFFfile("mandeldragon_orbits_" + caseNamesL[side] + "_ihst.tiff");
120
121 // Construct 8-bit RGB images
122 rcrt theRamCanvas(omaxRamCanvas.getNumPixX(), omaxRamCanvas.getNumPixY());
123
124 theRamCanvas.colorizeIntCanvas([&omaxRamCanvas, &ohstRamCanvas, &ihstRamCanvas](auto x, auto y) { return rcrt::colorType(static_cast<rcrt::colorChanType>(omaxRamCanvas.getPxColor(x, y).tfrmPow(0.8).getChan(0)/256),
125 static_cast<rcrt::colorChanType>(ohstRamCanvas.getPxColor(x, y).tfrmPow(0.3).getChan(0)/256),
126 static_cast<rcrt::colorChanType>(ihstRamCanvas.getPxColor(x, y).tfrmPow(0.8).getChan(0)/256)); });
127 theRamCanvas.writeTIFFfile("mandeldragon_orbits_" + caseNamesL[side] + "_color_838.tiff");
128
129 theRamCanvas.colorizeIntCanvas([&omaxRamCanvas, &ohstRamCanvas, &ihstRamCanvas](auto x, auto y) { return rcrt::colorType(static_cast<rcrt::colorChanType>(0),
130 static_cast<rcrt::colorChanType>(ohstRamCanvas.getPxColor(x, y).tfrmPow(0.3).getChan(0)/256),
131 static_cast<rcrt::colorChanType>(ihstRamCanvas.getPxColor(x, y).tfrmPow(0.8).getChan(0)/256)); });
132 theRamCanvas.writeTIFFfile("mandeldragon_orbits_" + caseNamesL[side] + "_color__Z38.tiff");
133
134 theRamCanvas.colorizeIntCanvas([&ohstRamCanvas](auto x, auto y) { return rcrt::colorType::csCCfractal0RYBCW::c(ohstRamCanvas.getPxColor(x, y).tfrmPow(0.3).getChan_dbl(0)); });
135 theRamCanvas.writeTIFFfile("mandeldragon_orbits_" + caseNamesL[side] + "_ohst_3csCCfractal0RYBCW.tiff");
136
137 theRamCanvas.colorizeIntCanvas([&ohstRamCanvas](auto x, auto y) { return rcrt::colorType::csCCdivBWR::c(ohstRamCanvas.getPxColor(x, y).tfrmPow(0.3).getChan_dbl(0)); });
138 theRamCanvas.writeTIFFfile("mandeldragon_orbits_" + caseNamesL[side] + "_ohst_3csCCdivBWR.tiff");
139
140 theRamCanvas.colorizeIntCanvas([&ohstRamCanvas](auto x, auto y) { return rcrt::colorType::csCCdivBWR::c(ohstRamCanvas.getPxColor(x, y).tfrmPow(0.5).getChan_dbl(0)); });
141 theRamCanvas.writeTIFFfile("mandeldragon_orbits_" + caseNamesL[side] + "_ohst_5csCCdivBWR.tiff");
142
143 theRamCanvas.colorizeIntCanvas([&ohstRamCanvas](auto x, auto y) { return rcrt::colorType::csPLYinferno::c(ohstRamCanvas.getPxColor(x, y).tfrmPow(0.5).getChan_dbl(0)); });
144 theRamCanvas.writeTIFFfile("mandeldragon_orbits_" + caseNamesL[side] + "_ohst_csPLYinferno.tiff");
145 }
146
147 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
148 std::cout << "Total Runtime " << runTime.count() << " sec" << std::endl;
149}
150/** @endcond */
int main(int argc, char *argv[])