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