diff --git a/README.md b/README.md index f87bb730..381edabd 100644 --- a/README.md +++ b/README.md @@ -57,4 +57,5 @@ Searching the Internet more... 2023/04/20 obj+ command. 2023/04/29 theoretical fix and their close on bump, afterbump, gettilevec chain. 2023/05/07 add functions around cvstereo.py. +2023/06/24 fix around z-axis scale on afterbump, get...vec, obj, tilt, sbox commands. diff --git a/goki.hh b/goki.hh index 3a4a691b..674916e7 100644 --- a/goki.hh +++ b/goki.hh @@ -616,6 +616,13 @@ template SimpleMatrix filter(const SimpleMatrix& data, const cerr << "i" << flush; resb += flip(flop(filter(flip(flop(result)), INTEGRAW_BOTH))); result = - (move(resb) /= T(int(4))); + T m(result(0, 0)); + for(int i = 0; i < result.rows(); i ++) + for(int j = 0; j < result.cols(); j ++) + m = min(m, result(i, j)); + for(int i = 0; i < result.rows(); i ++) + for(int j = 0; j < result.cols(); j ++) + result(i, j) -= m; } break; case AFTERBUMP: @@ -644,7 +651,6 @@ template SimpleMatrix filter(const SimpleMatrix& data, const for(int i = 0; i < result.rows(); i ++) for(int j = 0; j < result.cols(); j ++) result(i, j) += (rd - r) * T(i) + (cd - c) * T(j); - result = normalize(result); } break; case BLINK_Y: @@ -1239,7 +1245,7 @@ template static inline vector > mesh2(const vecto template vector > getTileVec(const SimpleMatrix& in, const int& vbox = 1) { vector > geoms; geoms.reserve((in.rows() / vbox + 1) * (in.cols() / vbox + 1)); - const auto diag(sqrt(T(in.rows() * in.rows() + in.cols() * in.cols()))); + const auto diag(sqrt(sqrt(T(in.rows() * in.rows() + in.cols() * in.cols())))); for(int i = 0; i < in.rows() / vbox + 1; i ++) for(int j = 0; j < in.cols() / vbox + 1; j ++) { if(in.rows() < (i + 1) * vbox || @@ -1276,7 +1282,7 @@ template vector > getHesseVec(const SimpleMatrix const auto xx(in * diff(in.cols()).transpose() * diff(in.cols()).transpose()); const auto xy(diff(in.rows()) * in * diff(in.cols()).transpose()); const auto yy(diff(in.rows()) * diff(in.rows()) * in); - const auto diag(sqrt(T(int(in.rows() * in.rows() + in.cols() * in.cols())))); + const auto diag(sqrt(sqrt(T(int(in.rows() * in.rows() + in.cols() * in.cols()))))); vector > > score; score.reserve(in.rows() * in.cols()); for(int i = 0; i < in.rows(); i ++) diff --git a/lieonn.hh b/lieonn.hh index 81e28aea..80f73354 100644 --- a/lieonn.hh +++ b/lieonn.hh @@ -4099,7 +4099,7 @@ template static inline SimpleVector autoLevel(const SimpleVector b.resize(1); b[0].resize(1, data.size()); b[0].row(0) = data; - return autoLevel(b)[0].row(0); + return autoLevel(b, count)[0].row(0); } #define _SIMPLELIN_ diff --git a/test.py b/test.py index 6daa7d18..790d9648 100644 --- a/test.py +++ b/test.py @@ -152,10 +152,7 @@ subprocess.call(["python3", argv[0], argv[1], "jps", line]) subprocess.call(["gokicvs", root]) subprocess.call(["python3", argv[0], argv[1], "nop", root + "-bumps.png"]) - subprocess.call(["python3", argv[0], argv[1], "jpsr", line]) - subprocess.call(["gokicvs", root]) - subprocess.call(["python3", argv[0], argv[1], "nop", root + "-bumps.png"]) - subprocess.call(["python3", argv[0], argv[1], "objr", line]) + subprocess.call(["python3", argv[0], argv[1], "Objr", line]) subprocess.call(["python3", argv[0], argv[1], "jpsr", line]) elif(argv[2] == "obj" or argv[2] == "Obj" or argv[2] == "obj+" or argv[2] == "Obj+"): subprocess.call([argv[1], argv[2], str(rot), root + "-bump.ppm", root + ".obj"]) diff --git a/tools.cc b/tools.cc index c0a0612c..6aac731f 100644 --- a/tools.cc +++ b/tools.cc @@ -112,7 +112,7 @@ int main(int argc, const char* argv[]) { else if(strcmp(argv[1], "represent") == 0) data[0] = data[1] = data[2] = filter(rgb2d(data), REPRESENT, recur); else if(strcmp(argv[1], "bump") == 0) - data[0] = data[1] = data[2] = autoLevel(filter(rgb2d(data), BUMP_BOTH, recur, rot), 4 * (data[0].rows() + data[0].cols()) ); + data[0] = data[1] = data[2] = filter(rgb2d(data), BUMP_BOTH, recur, rot); else if(strcmp(argv[1], "w2b") == 0) { for(int i = 0; i < data[0].rows(); i ++) for(int j = 0; j < data[0].cols(); j ++) @@ -165,7 +165,8 @@ int main(int argc, const char* argv[]) { } if(!savep2or3(argv[3], strcmp(argv[1], "b2w") != 0 && strcmp(argv[1], "b2wd") != 0 && - strcmp(argv[1], "nop") != 0 && strcmp(argv[1], "limit") != 0 + strcmp(argv[1], "nop") != 0 && strcmp(argv[1], "limit") != 0 && + strcmp(argv[1], "bump") != 0 ? normalize(data) : data, strcmp(argv[1], "limit") == 0 ? recur : 65535) ) return - 1; @@ -223,8 +224,7 @@ int main(int argc, const char* argv[]) { if(!loadp2or3(data, argv[3])) return - 1; auto sd(argv[1][strlen("obj")] == 'r' ? - shrinkd(rgb2d(data), argv[1][strlen("objr")]) / - sqrt(sqrt(num_t(data[0].rows() * data[0].rows() + data[0].cols() * data[0].cols()) )) : + shrinkd(rgb2d(data), argv[1][strlen("objr")]) : shrinkd(filter(rgb2d(data), AFTERBUMP, 2, std::atoi(argv[2])), argv[1][strlen("obj")]) ); const auto rows(sd.rows()); const auto cols(sd.cols()); @@ -260,8 +260,7 @@ int main(int argc, const char* argv[]) { assert(strlen("tilt" ) == strlen("sbox" )); assert(strlen("tiltr") == strlen("sboxr")); bump[0] = argv[1][strlen("tilt")] == 'r' ? - shrinkde(rgb2d(bump), argv[1][strlen("tiltr")]) / - sqrt(sqrt(num_t(bump[0].rows() * bump[0].rows() + bump[0].cols() * bump[0].cols()) )) : + shrinkde(rgb2d(bump), argv[1][strlen("tiltr")]) : shrinkde(filter(rgb2d(bump), AFTERBUMP), argv[1][strlen("tilt")]); num_t z0(int(0)); for(int i = 0; i < bump[0].rows(); i ++)