bonej-org / BoneJ2

Plugins for bone image analysis
BSD 2-Clause "Simplified" License
20 stars 12 forks source link

Surface Area complains that axis calibrations are different when they are the same #260

Open mdoube opened 4 years ago

mdoube commented 4 years ago

Describe the bug Surface Area always complains that axis calibration is different even when it is the same, then returns an uncalibrated surface area.

To Reproduce Steps to reproduce the behavior:

  1. Open a 3D binary image with isotropic pixel spacing
  2. Run Plugins > BoneJ > Surface Area
  3. Note the warning message and uncalibrated result

Expected behavior Surface Area runs without a warning and returns a calibrated result

Context Seems to be in this method. All its tests pass, but there isn't a test for "axis calibrations are the same and no warning is shown" https://github.com/bonej-org/BoneJ2/blob/2de395e1c13d3a4bc3de75facc190eba9277514a/Modern/wrapperPlugins/src/main/java/org/bonej/wrapperPlugins/SurfaceAreaWrapper.java#L176

mdoube commented 4 years ago

There is a better way to do this which is to multiply the x, y, z coordinates of the surface mesh vertices by pixel width, height and depth just prior to calculating the cross product. The area produced will be calibrated and can handle any anisotropy.

It would still be helpful to know whether the units of each axis are different, (e.g. pixels in z but mm in xy), although that is not possible in ImagePlus Calibration, it might be in ImageJ2-land. If units are indeed different then that would be a user thing to fix - too hard to do all the possible conversions.

mdoube commented 4 years ago

Hi @ctrueden, could you please point to where meshes are actually made in the Ops? I get stuck in Interfaces when F3-ing through method calls in Eclipse, and never seem to get to the meat of the code where the work is done. Ideally the mesh would be calibrated using the input image's calibration (so that the vertex positions are in real units), so that no further calibration is required.

mdoube commented 4 years ago

This issue is closely related to and will largely be addressed by fixes to #234 , in which calibrated surface meshes will be produed by the Op.