33#include "ramCanvas.hpp"
34#include "MRMathSTR.hpp"
37int main(
int argc,
char *argv[]) {
38 std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
39 std::random_device rd;
40 std::minstd_rand0 rEng(rd());
41 mjr::ramCanvas3c8b theRamCanvas(7680/2, 4320/2, -2.2, 2.2, -2.2, 2.2);
42 theRamCanvas.clrCanvas(mjr::ramCanvas3c8b::colorType(255, 0, 0));
43 int MAXCOUNT = 524288;
45 int stenX[8] = {1, -1, 0, 0, 1, 1, -1, -1};
46 int stenY[8] = {0, 0, 1, -1, 1, -1, 1, -1};
49 if((argc < 3) || (argc > 4)) {
50 std::cout <<
"ERROR: Useage: dlaBrownian inFile.tiff outFile_without_extension [ITERATIONS]" << std::endl;
53 if(theRamCanvas.readTIFFfile(argv[1])) {
54 std::cout <<
"ERROR: Problem with file: " << argv[2] << std::endl;
59 MAXCOUNT = std::stoi(argv[3]);
61 for(
int tgtLumPct=1;tgtLumPct<=100;tgtLumPct+=10) {
62 double tgtLum=tgtLumPct / 100.0;
64 for(
int numItr=1;numItr<MAXCOUNT;numItr++) {
65 mjr::ramCanvas3c8b::coordIntType xC, yC;
66 xC =
static_cast<int>(rEng() % theRamCanvas.getNumPixX());
67 yC =
static_cast<int>(rEng() % theRamCanvas.getNumPixY());
69 mjr::ramCanvas3c8b::colorType aColor = theRamCanvas.getPxColor(xC, yC);
70 double lumC = aColor.luminanceRGB();
72 if((lumC > 0) && (lumC < tgtLum)) {
76 for(
int curDir=0; curDir<8; curDir++) {
77 mjr::ramCanvas3c8b::coordIntType xN, yN;
78 xN = xC+stenX[curDir];
79 yN = yC+stenY[curDir];
80 if(xN>=0 && yN>=0 && xN<theRamCanvas.getNumPixX() && yN<theRamCanvas.getNumPixY()) {
81 double lumN = theRamCanvas.getPxColor(xN, yN).luminanceRGB();
85 if((lumN > lumC) && (maxLum < lumN)) {
95 int curDir = rEng() % 8;
96 mjr::ramCanvas3c8b::coordIntType xN, yN;
97 xN = xC+stenX[curDir];
98 yN = yC+stenY[curDir];
99 if(xN>=0 && yN>=0 && xN<theRamCanvas.getNumPixX() && yN<theRamCanvas.getNumPixY()) {
105 mjr::ramCanvas3c8b::coordIntType xN, yN;
106 xN = xC+stenX[maxDir];
107 yN = yC+stenY[maxDir];
109 theRamCanvas.getPxColorRefNC(xN, yN).tfrmAdd(aColor);
110 theRamCanvas.drawPoint(xC, yC, mjr::ramCanvas3c8b::colorType(0, 0, 0));
115 theRamCanvas.writeTIFFfile(argv[2] + mjr::math::str::fmt_int(tgtLumPct, 3,
'0') +
".tiff");
116 std::cout <<
"Write: " << tgtLumPct << std::endl;
119 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
120 std::cout <<
"Total Runtime " << runTime.count() <<
" sec" << std::endl;
int main(int argc, char *argv[])