Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Potential mathmatics error #12

Open
PascalYIN opened this issue Sep 2, 2019 · 1 comment
Open

Potential mathmatics error #12

PascalYIN opened this issue Sep 2, 2019 · 1 comment

Comments

@PascalYIN
Copy link

PascalYIN commented Sep 2, 2019

Hello, I'm re-reading the Sobolev fusion paper and I was confused by the Sobolev approximation part. So I re-read your code for a better comprehension, then I found the way that you calculate the laplacien matrix is weird :
`cv::Mat L_mat = -6.f * cv::Mat::eye(s3, s3, CV_32FC1);
for (int i = 0; i <= static_cast(pow(params.s, 3)) - 1; ++i) {
int idx_z = i / (params.s * params.s);
int idx_y = (i - idx_z * params.s * params.s) / params.s;
int idx_x = i - params.s * (idx_y + params.s * idx_z);
if (idx_x + 1 < params.s) {
int pos = (idx_x + 1) + idx_y * params.s + idx_z * params.s * params.s;
L_mat.at(i, pos) = 1.f;
}
if (idx_x - 1 >= 0) {
int pos = (idx_x - 1) + idx_y * params.s + idx_z * params.s * params.s;
L_mat.at(i, pos) = 1.f;
}

    if (idx_y + 1 < params.s) {
        int pos                 = idx_x + (idx_y + 1) * params.s + idx_z * params.s * params.s;
        L_mat.at<float>(i, pos) = 1.f;
    }
    if (idx_y - 1 >= 0) {
        int pos                 = idx_x + (idx_y - 1) * params.s + idx_z * params.s * params.s;
        L_mat.at<float>(i, pos) = 1.f;
    }

    if (idx_z + 1 < params.s) {
        int pos                 = idx_x + idx_y * params.s + (idx_z + 1) * params.s * params.s;
        L_mat.at<float>(i, pos) = 1.f;
    }
    if (idx_z - 1 >= 0) {
        int pos                 = idx_x + idx_y * params.s + (idx_z - 1) * params.s * params.s;
        L_mat.at<float>(i, pos) = 1.f;
    }
}`

I checked the definition of laplacian matrix on wikipedia,
image
As the diagonal of tha laplacian matrix should be the row-wise sum of the correspondant adjacency matrix, it shouldn't be -6 for all, and the L_mat.at<float>(i,pos) should be -1.f, am I right?

@dgrzech
Copy link
Owner

dgrzech commented Oct 30, 2019

here's a document that shows how to construct a sparse Laplacian matrix for a 3D grid: https://www.12000.org/my_notes/mma_matlab_control/KERNEL/KEse83.htm why would the diagonal of L be the row-wise sum of the adjacency matrix, and not simply be equal to the diagonal of the adjacency matrix?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants