Skip to content

Commit 789cdb2

Browse files
committed
Preserve differentiation in summation from plugin
1 parent cbebe43 commit 789cdb2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/main/java/net/imagej/ops/filter/sharpen/DefaultSharpen.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import net.imglib2.algorithm.neighborhood.RectangleNeighborhood;
1515
import net.imglib2.algorithm.neighborhood.RectangleNeighborhoodFactory;
1616
import net.imglib2.algorithm.neighborhood.RectangleShape.NeighborhoodsAccessible;
17+
import net.imglib2.type.numeric.IntegerType;
1718
import net.imglib2.type.numeric.RealType;
1819
import net.imglib2.util.Util;
1920
import net.imglib2.view.Views;
@@ -119,8 +120,15 @@ private void computePlanar(final Position planePos,
119120
for (int i = 0; i < kernel.length; i++) {
120121
sum += kernel[i] * n[i];
121122
}
122-
123-
double value = sum / scale;
123+
124+
//find the value for the output
125+
double value;
126+
if(type instanceof IntegerType) {
127+
value = (sum + scale / 2) / scale;
128+
}
129+
else {
130+
value = sum / scale;
131+
}
124132

125133
outputRA.setPosition(cursor.getLongPosition(0), 0);
126134
outputRA.setPosition(cursor.getLongPosition(1), 1);

0 commit comments

Comments
 (0)