Skip to content

Commit

Permalink
Preserve differentiation in summation from plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
gselzer committed Jan 18, 2019
1 parent 9579493 commit 2b44404
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/main/java/net/imagej/ops/filter/sharpen/DefaultSharpen.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.imglib2.algorithm.neighborhood.RectangleNeighborhood;
import net.imglib2.algorithm.neighborhood.RectangleNeighborhoodFactory;
import net.imglib2.algorithm.neighborhood.RectangleShape.NeighborhoodsAccessible;
import net.imglib2.type.numeric.IntegerType;
import net.imglib2.type.numeric.RealType;
import net.imglib2.util.Util;
import net.imglib2.view.Views;
Expand Down Expand Up @@ -119,8 +120,15 @@ private void computePlanar(final Position planePos,
for (int i = 0; i < kernel.length; i++) {
sum += kernel[i] * n[i];
}

double value = sum / scale;

//find the value for the output
double value;
if(type instanceof IntegerType) {
value = (sum + scale / 2) / scale;
}
else {
value = sum / scale;
}

outputRA.setPosition(cursor.getLongPosition(0), 0);
outputRA.setPosition(cursor.getLongPosition(1), 1);
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/net/imagej/ops/filter/smooth/DefaultSmooth.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.imglib2.algorithm.neighborhood.RectangleNeighborhood;
import net.imglib2.algorithm.neighborhood.RectangleNeighborhoodFactory;
import net.imglib2.algorithm.neighborhood.RectangleShape.NeighborhoodsAccessible;
import net.imglib2.type.numeric.IntegerType;
import net.imglib2.type.numeric.RealType;
import net.imglib2.util.Util;
import net.imglib2.view.Views;
Expand Down Expand Up @@ -119,7 +120,14 @@ private void computePlanar(final Position planePos,
sum += kernel[i] * n[i];
}

double value = sum / scale;
//find the value for the output
double value;
if(type instanceof IntegerType) {
value = (sum + scale / 2) / scale;
}
else {
value = sum / scale;
}

outputRA.setPosition(cursor.getLongPosition(0), 0);
outputRA.setPosition(cursor.getLongPosition(1), 1);
Expand Down

0 comments on commit 2b44404

Please sign in to comment.