diff --git a/src/main/java/net/imagej/ops/filter/sharpen/DefaultSharpen.java b/src/main/java/net/imagej/ops/filter/sharpen/DefaultSharpen.java index de68d042e0..45a6a3ca31 100644 --- a/src/main/java/net/imagej/ops/filter/sharpen/DefaultSharpen.java +++ b/src/main/java/net/imagej/ops/filter/sharpen/DefaultSharpen.java @@ -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; @@ -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); diff --git a/src/main/java/net/imagej/ops/filter/smooth/DefaultSmooth.java b/src/main/java/net/imagej/ops/filter/smooth/DefaultSmooth.java index 3d64239184..3f443db32b 100644 --- a/src/main/java/net/imagej/ops/filter/smooth/DefaultSmooth.java +++ b/src/main/java/net/imagej/ops/filter/smooth/DefaultSmooth.java @@ -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; @@ -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);