Skip to content
Snippets Groups Projects
Commit d80ef09b authored by Céline  TREBEAU's avatar Céline TREBEAU
Browse files

The "zero" values are not taken into account.

parent af25ac72
No related branches found
No related tags found
1 merge request!10Surface reconstruction Refactoring
...@@ -8,6 +8,7 @@ import net.imglib2.RandomAccessibleInterval; ...@@ -8,6 +8,7 @@ import net.imglib2.RandomAccessibleInterval;
import net.imglib2.algorithm.neighborhood.Neighborhood; import net.imglib2.algorithm.neighborhood.Neighborhood;
import net.imglib2.algorithm.neighborhood.RectangleShape; import net.imglib2.algorithm.neighborhood.RectangleShape;
import net.imglib2.img.Img; import net.imglib2.img.Img;
import net.imglib2.img.display.imagej.ImageJFunctions;
import net.imglib2.type.NativeType; import net.imglib2.type.NativeType;
import net.imglib2.type.numeric.RealType; import net.imglib2.type.numeric.RealType;
import net.imglib2.view.IntervalView; import net.imglib2.view.IntervalView;
...@@ -39,6 +40,7 @@ public class Filter2D<T extends RealType<T> & NativeType<T>> { ...@@ -39,6 +40,7 @@ public class Filter2D<T extends RealType<T> & NativeType<T>> {
public static <T extends RealType<T> & NativeType<T>> Img<T> mean(final Img<T> source, final int radius) { public static <T extends RealType<T> & NativeType<T>> Img<T> mean(final Img<T> source, final int radius) {
Process<T> p = new Process<>(source, radius, "mean"); Process<T> p = new Process<>(source, radius, "mean");
p.run(); p.run();
return p.output; return p.output;
} }
...@@ -64,8 +66,9 @@ public class Filter2D<T extends RealType<T> & NativeType<T>> { ...@@ -64,8 +66,9 @@ public class Filter2D<T extends RealType<T> & NativeType<T>> {
final IntervalView<T> outputSlice = Views.hyperSlice(output, 2, z); final IntervalView<T> outputSlice = Views.hyperSlice(output, 2, z);
ProcessSlice<T> p = new ProcessSlice<>(slice, outputSlice, radius); ProcessSlice<T> p = new ProcessSlice<>(slice, outputSlice, radius);
p.run(method); p.run(method);
} }ImageJFunctions.show( output.copy(), method );
} }
} }
public static class ProcessSlice<T extends RealType<T> & NativeType<T>> { public static class ProcessSlice<T extends RealType<T> & NativeType<T>> {
...@@ -112,9 +115,12 @@ public class Filter2D<T extends RealType<T> & NativeType<T>> { ...@@ -112,9 +115,12 @@ public class Filter2D<T extends RealType<T> & NativeType<T>> {
double sum = 0; double sum = 0;
for (final T pixel : nra.get()) { for (final T pixel : nra.get()) {
double value = pixel.getRealDouble(); double value = pixel.getRealDouble();
values[index] = value; if(value != 0)
sum = sum + value; {
index++; values[ index ] = value;
sum = sum + value;
index++;
}
} }
return sum / (index); return sum / (index);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment