Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Commit

Permalink
make clean around bump with z-axis cv2.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitsofcotton committed Jun 24, 2023
1 parent 472b1cc commit dd269dc
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

12 changes: 9 additions & 3 deletions goki.hh
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,13 @@ template <typename T> SimpleMatrix<T> filter(const SimpleMatrix<T>& data, const
cerr << "i" << flush;
resb += flip<T>(flop<T>(filter<T>(flip<T>(flop<T>(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:
Expand Down Expand Up @@ -644,7 +651,6 @@ template <typename T> SimpleMatrix<T> filter(const SimpleMatrix<T>& 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<T>(result);
}
break;
case BLINK_Y:
Expand Down Expand Up @@ -1239,7 +1245,7 @@ template <typename T> static inline vector<SimpleVector<int> > mesh2(const vecto
template <typename T> vector<SimpleVector<T> > getTileVec(const SimpleMatrix<T>& in, const int& vbox = 1) {
vector<SimpleVector<T> > 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 ||
Expand Down Expand Up @@ -1276,7 +1282,7 @@ template <typename T> vector<SimpleVector<T> > getHesseVec(const SimpleMatrix<T>
const auto xx(in * diff<T>(in.cols()).transpose() * diff<T>(in.cols()).transpose());
const auto xy(diff<T>(in.rows()) * in * diff<T>(in.cols()).transpose());
const auto yy(diff<T>(in.rows()) * diff<T>(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<pair<T, pair<int, int> > > score;
score.reserve(in.rows() * in.cols());
for(int i = 0; i < in.rows(); i ++)
Expand Down
2 changes: 1 addition & 1 deletion lieonn.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4099,7 +4099,7 @@ template <typename T> static inline SimpleVector<T> autoLevel(const SimpleVector
b.resize(1);
b[0].resize(1, data.size());
b[0].row(0) = data;
return autoLevel<T>(b)[0].row(0);
return autoLevel<T>(b, count)[0].row(0);
}

#define _SIMPLELIN_
Expand Down
5 changes: 1 addition & 4 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
11 changes: 5 additions & 6 deletions tools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<num_t>(rgb2d<num_t>(data), REPRESENT, recur);
else if(strcmp(argv[1], "bump") == 0)
data[0] = data[1] = data[2] = autoLevel<num_t>(filter<num_t>(rgb2d<num_t>(data), BUMP_BOTH, recur, rot), 4 * (data[0].rows() + data[0].cols()) );
data[0] = data[1] = data[2] = filter<num_t>(rgb2d<num_t>(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 ++)
Expand Down Expand Up @@ -165,7 +165,8 @@ int main(int argc, const char* argv[]) {
}
if(!savep2or3<num_t>(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<num_t>(data) : data,
strcmp(argv[1], "limit") == 0 ? recur : 65535) )
return - 1;
Expand Down Expand Up @@ -223,8 +224,7 @@ int main(int argc, const char* argv[]) {
if(!loadp2or3<num_t>(data, argv[3]))
return - 1;
auto sd(argv[1][strlen("obj")] == 'r' ?
shrinkd<num_t>(rgb2d<num_t>(data), argv[1][strlen("objr")]) /
sqrt(sqrt(num_t(data[0].rows() * data[0].rows() + data[0].cols() * data[0].cols()) )) :
shrinkd<num_t>(rgb2d<num_t>(data), argv[1][strlen("objr")]) :
shrinkd<num_t>(filter<num_t>(rgb2d<num_t>(data), AFTERBUMP, 2, std::atoi(argv[2])), argv[1][strlen("obj")]) );
const auto rows(sd.rows());
const auto cols(sd.cols());
Expand Down Expand Up @@ -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<num_t>(rgb2d<num_t>(bump), argv[1][strlen("tiltr")]) /
sqrt(sqrt(num_t(bump[0].rows() * bump[0].rows() + bump[0].cols() * bump[0].cols()) )) :
shrinkde<num_t>(rgb2d<num_t>(bump), argv[1][strlen("tiltr")]) :
shrinkde<num_t>(filter<num_t>(rgb2d<num_t>(bump), AFTERBUMP), argv[1][strlen("tilt")]);
num_t z0(int(0));
for(int i = 0; i < bump[0].rows(); i ++)
Expand Down

0 comments on commit dd269dc

Please sign in to comment.