MRaster examples 22.0.0.0
Image Processing Library
Loading...
Searching...
No Matches
tricorn_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 tricorn_orbits.cpp
5 @author Mitch Richling <https://www.mitchr.me>
6 @brief Tricorn 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 @verbatim
31 magick \‍( tricorn_orbits_ohst.tiff -evaluate Pow 0.4 -despeckle \‍) ../docs/pics/cs/color_lut_docs_csCCwicB_50.png -clut -rotate 90 tricorn_orbits_csCCwicB.png; nomacs tricorn_orbits_csCCwicB.png &
32
33 magick \‍( tricorn_orbits_ohst.tiff -evaluate Pow 0.3 -despeckle \‍) ../docs/pics/cs/color_lut_docs_csPLYinferno_50.png -clut -rotate 90 tricorn_orbits_csPLYinferno.png; nomacs tricorn_orbits_csPLYinferno.png &
34
35 magick \‍( tricorn_orbits_ohst.tiff -evaluate Pow 0.3 \‍) \‍( tricorn_orbits_ihst.tiff -evaluate Pow 0.8 \‍) \‍( tricorn_orbits_oirt.tiff -evaluate Pow 0.7 -despeckle -blur 10 \‍) -combine -rotate 90 tricorn_orbits_composite.png; nomacs tricorn_orbits_composite.png &
36 @endverbatim
37*/
38/*******************************************************************************************************************************************************.H.E.**/
39/** @cond exj */
40
41//--------------------------------------------------------------------------------------------------------------------------------------------------------------
42#include "ramCanvas.hpp"
43#include "MRMathCPLX.hpp"
44
45//--------------------------------------------------------------------------------------------------------------------------------------------------------------
46typedef mjr::ramCanvas1c16b rcct;
47typedef mjr::ramCanvas3c8b rcrt;
48
49//--------------------------------------------------------------------------------------------------------------------------------------------------------------
50int main(void) {
51 std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
52 const int csize = 7680/8;
53 const int maxitr = 256*4;
54 const double escRad = 5.0;
55 const double z0r = 0.0;
56 const double z0i = 0.0;
57 const int resMul = 8;
58 const double sweepXmin = -2.0;
59 const double sweepXmax = 2.0;
60 const int sweepXres = csize*resMul;
61 const double sweepXdel = (sweepXmax-sweepXmin)/sweepXres;;
62 const int sweepYres = csize*resMul;
63 const double sweepYmin = -2.0;
64 const double sweepYmax = 2.0;
65 const double sweepYdel = (sweepYmax-sweepYmin)/sweepYres;
66 const double drawXmin = -1.8;
67 const double drawXmax = 1.2;
68 const double drawYmin = -1.5;
69 const double drawYmax = 1.5;
70
71 rcct ihstRamCanvas(csize, csize, drawXmin, drawXmax, drawYmin, drawYmax); // Interior points histogram
72 rcct imagRamCanvas(csize, csize, drawXmin, drawXmax, drawYmin, drawYmax); // Interior points minimum distance to origin
73 rcct ohstRamCanvas(csize, csize, drawXmin, drawXmax, drawYmin, drawYmax); // Exterior points histogram
74 rcct oirtRamCanvas(csize, csize, drawXmin, drawXmax, drawYmin, drawYmax); // Exterior points max iteration for point
75 rcct ojmpRamCanvas(csize, csize, drawXmin, drawXmax, drawYmin, drawYmax); // Exterior points max jump to point
76 std::complex<double>* theOrbit = new std::complex<rcct::coordFltType>[maxitr+1];
77
78 for(int y=0;y<sweepYres;y++) {
79 if((y%(sweepYres/16))==0)
80 std::cout << "LINE: " << y << "/" << sweepYres << std::endl;
81 for(int x=0;x<sweepXres;x++) {
82 std::complex<rcct::coordFltType> c(x * sweepXdel + sweepXmin, y * sweepYdel + sweepYmin);
83 std::complex<rcct::coordFltType> z(z0r, z0i);
84 for(rcct::colorChanType count=0; ; count++) {
85 z = std::pow(std::conj(z), 2) + c ;
86 if(std::abs(z)>escRad) {
87 for(rcct::colorChanType i=10; i<=count; i++) {
88 ohstRamCanvas.incPxChan(theOrbit[i]);
89 oirtRamCanvas.tformPixel(theOrbit[i], [i](auto& c) { c.tfrmMax(i); });
90 rcct::colorChanType dst = static_cast<rcct::colorChanType>(std::abs(theOrbit[i]-theOrbit[i-1]) / escRad * rcct::colorType::maxChanVal);
91 ojmpRamCanvas.tformPixel(theOrbit[i], [dst](auto& c) { c.tfrmMax(dst); });
92 }
93 break;
94 } else if(count>=(maxitr-1)) {
95 for(rcct::colorChanType i=10; i<=count; i++) {
96 rcct::colorChanType dst = static_cast<rcct::colorChanType>(std::abs(theOrbit[i]) / escRad * rcct::colorType::maxChanVal);
97 imagRamCanvas.tformPixel(theOrbit[i], [dst](auto& c) { if(c.isBlack()) c.setC0(dst); else c.tfrmMin(dst); });
98 ihstRamCanvas.incPxChan(theOrbit[i]);
99 }
100 break;
101 }
102 theOrbit[count] = z;
103 }
104 }
105 }
106
107 // Dump out our "data" images
108 oirtRamCanvas.autoHistStrech();
109 oirtRamCanvas.writeTIFFfile("tricorn_orbits_oirt.tiff");
110 ohstRamCanvas.autoHistStrech();
111 ohstRamCanvas.writeTIFFfile("tricorn_orbits_ohst.tiff");
112 ihstRamCanvas.autoHistStrech();
113 ihstRamCanvas.writeTIFFfile("tricorn_orbits_ihst.tiff");
114 ojmpRamCanvas.autoHistStrech();
115 ojmpRamCanvas.writeTIFFfile("tricorn_orbits_ojmp.tiff");
116 imagRamCanvas.autoHistStrech();
117 imagRamCanvas.writeTIFFfile("tricorn_orbits_imag.tiff");
118
119 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
120 std::cout << "Total Runtime " << runTime.count() << " sec" << std::endl;
121}
122/** @endcond */
int main(int argc, char *argv[])