educelab / volume-cartographer

Volumetric processing toolkit and C++ libraries for the recovery and restoration of damaged cultural materials
GNU General Public License v3.0
63 stars 22 forks source link

[Bug] Typo in the linear interpolation formula, in Volume::interpolateAt() #104

Closed Paul-G2 closed 2 months ago

Paul-G2 commented 2 months ago

What happened?

I believe there's a bug in the interpolateAt() method in the Volume class. The line

const auto c10 = intensityAt(x0, y1, z0) * (1 - dx) + intensityAt(x1, y0, z0) * dx;

should be

const auto c10 = intensityAt(x0, y1, z0) * (1 - dx) + intensityAt(x1, y1, z0) * dx;

ie, the y0 on the right-hand side should be y1. This line is interpolating in x, so y should remain constant.

I guess this will affect many vc outputs. I found it while trying to implement a Python version of vc_layers_from_ppm. I kept getting small differences in the pixel values produced by vc and those produced by the scipy.interpolate methods. As an example, on a layer image whose mean pixel value was about 30,000, the standard deviation of pixel differences was about 700, with a few outliers as large as 15000. Visually, the images were nearly indistinguishable. (When I made the above change in Volume.cpp, the vc output matched the python result exactly.)

Steps to reproduce

n/a

Version

All versions

How did you install the software?

Docker

On which operating systems have you experienced this issue?

Relevant log output

No response

Code of Conduct

csparker247 commented 2 months ago

Thanks. I'll investigate tomorrow to confirm, but it certainly seems like a bug!

csparker247 commented 2 months ago

Sure enough! Thanks for finding it. This will be fixed in #105.