MRaster examples 21.0.0.0
Image Processing Library
Loading...
Searching...
No Matches
mandelbrot_precomp_p1.cpp
Go to the documentation of this file.
1// -*- Mode:C++; Coding:us-ascii-unix; fill-column:158 -*-
2/*******************************************************************************************************************************************************.H.S.**/
3/**
4 @file mandelbrot_precomp_p1.cpp
5 @author Mitch Richling <https://www.mitchr.me>
6 @brief Produce several images related to the period/cycle structure of the Mandelbrot set.@EOL
7 @std C++20
8 @copyright
9 @parblock
10 Copyright (c) 1988-2015,2021 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*/
30/*******************************************************************************************************************************************************.H.E.**/
31/** @cond exj */
32
33//--------------------------------------------------------------------------------------------------------------------------------------------------------------
34#include "ramCanvas.hpp"
35
36typedef mjr::ramCanvas1c16b rcCNT; // for counts!
37typedef mjr::ramCanvas3c8b rcC8;
38
39//--------------------------------------------------------------------------------------------------------------------------------------------------------------
40int main(void) {
41 std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
42 rcC8::colorType limitColor("red");
43 rcC8::colorType setColor("yellow");
44
45 const int MCSIZE = 7680;
46 const int CSIZEF = 1;
47 const int CSIZE = MCSIZE/CSIZEF;
48 rcC8 theRamCanvas(CSIZE, CSIZE, -2.1, 0.75, -1.4, 1.4);
49 rcCNT perRamCanvas;
50 rcCNT stbRamCanvas;
51
52 perRamCanvas.readTIFFfile("../precomp/mandelbrot_precompPER.tiff");
53 stbRamCanvas.readTIFFfile("../precomp/mandelbrot_precompSTB.tiff");
54# pragma omp parallel for schedule(static,1)
55 for(int y=0;y<theRamCanvas.getNumPixY();y++) {
56 for(int x=0;x<theRamCanvas.getNumPixX();x++) {
57 auto inten = theRamCanvas.getPxColorNC(x, y).intensity();
58 auto period = perRamCanvas.getPxColorNC(x, y).getC0();
59 if (period > 0) {
60 if (inten == 0)
61 theRamCanvas.drawPoint(x, y, setColor);
62 auto itrreq = stbRamCanvas.getPxColorNC(x, y).getC0();
63 std::complex<double> c = theRamCanvas.int2real(x, y);
64 std::complex<double> z(0.0, 0.0);
65 rcCNT::colorChanType count = 1;
66 while (count<itrreq) {
67 z=std::pow(z, 2) + c;
68 count++;
69 }
70 count = 0;
71 while (count<period) {
72 z=std::pow(z, 2) + c;
73 theRamCanvas.drawPoint(z, limitColor);
74 count++;
75 }
76 }
77 }
78 if ((y%10)==0)
79 std::cout << y << std::endl;
80 }
81
82 theRamCanvas.writeTIFFfile("mandelbrot_precomp_p1_br.tiff");
83 theRamCanvas.rotate90CW();
84 theRamCanvas.writeTIFFfile("mandelbrot_precomp_p1_ar.tiff");
85 theRamCanvas.scaleDownMean(4);
86 theRamCanvas.writeTIFFfile("mandelbrot_precomp_p1.tiff");
87
88 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
89 std::cout << "Total Runtime " << runTime.count() << " sec" << std::endl;
90}
91/** @endcond */
int main(int argc, char *argv[])