imagej / imagej-ops

ImageJ Ops: "Write once, run anywhere" image processing
https://imagej.net/libs/imagej-ops
BSD 2-Clause "Simplified" License
88 stars 42 forks source link

Reduce pixel lookups #635

Closed mdoube closed 3 years ago

mdoube commented 3 years ago

Suggested by Matthias Arzt @maarzt https://github.com/maarzt/imagej-ops/commit/5e1ef886b3f84ea278c5710c0d89638f9fcaaba8#diff-a06b9f93651e2b6be331719c7f00d7af4a3460fc8dff3987dcc5edfa9b20c9fd Re-uses pixel values by looking up only values new to the octant. Brings the Op into line with the current Legacy Connectivity in BoneJ.

mdoube commented 3 years ago

Getting a very slightly different result than I should. Please hold this while I figure it out.

mdoube commented 3 years ago

Getting a very weird bug with this. Correct answer obtained initially on workstation, but then out by a fractional amount later. Now correct answer on laptop and incorrect answer on workstation, running the same code. Both up-to-date Fiji installations just with a dev build of imagej-ops replacing the user build:

mvn clean package -DskipTests; cp target/imagej-ops-0.45.8-SNAPSHOT.jar ../../Fiji.app.dev/jars/
Bugged result: Label Euler ch. Δ(χ) Connectivity Conn.D (mm^-3)
umzc_378p_Apteryx_haastii_head.tif -284.875 -235.25 236.25 3.7970210319403397
Correct result (Legacy Connectivity) Label Euler ch. Δ(χ) Connectivity Conn.D (mm^-3) Legacy (ms) Modern (ms)
umzc_378p_Apteryx_haastii_head.tif -285 -235.375 236.375 3.799 461 2116

Both using this test image: umzc_378p_Apteryx_haastii_head.zip

Needs a unit test and a bit more thought. Alternatively given the poor performance relative to the Legacy version, a total redesign of the multithreading / iteration strategy.

mdoube commented 3 years ago

This is the test script:

//Warm-up
run("Clear Results");
run("Clear BoneJ results");

for (i = 0; i < 5; i++){
    run("Connectivity");
    run("Connectivity (Modern)");
}

run("Clear Results");
run("Clear BoneJ results");
wait(1000);

for (i = 0; i < 10; i++) {
    //Legacy
    start = getTime();
    run("Connectivity");
    end = getTime();
    setResult("Legacy (ms)", nResults - 1, (end-start));
    //Modern
    start = getTime();
    run("Connectivity (Modern)");
    end = getTime();
    setResult("Modern (ms)", nResults - 1, (end-start));
    updateResults();
}