Ejemplo n.º 1
0
 /**
  * Apply Gaussian convolution to source and write the result to output. In-place operation
  * (source==target) is supported.
  *
  * <p>If the target type T is {@link DoubleType}, all calculations are done in double precision.
  * For all other target {@link RealType RealTypes} float precision is used. General {@link
  * NumericType NumericTypes} are computed in their own precision. The source type S and target
  * type T are either both {@link RealType RealTypes} or both the same type.
  *
  * @param sigma standard deviation of isotropic Gaussian.
  * @param source source image, must be sufficiently padded (e.g. {@link
  *     Views#extendMirrorSingle(RandomAccessibleInterval)}) to provide values for the target
  *     interval plus a border of half the kernel size.
  * @param target target image
  * @param <S> source type
  * @param <T> target type
  * @throws IncompatibleTypeException if source and target type are not compatible (they must be
  *     either both {@link RealType RealTypes} or the same type).
  */
 public static <S extends NumericType<S>, T extends NumericType<T>> void gauss(
     final double sigma,
     final RandomAccessible<S> source,
     final RandomAccessibleInterval<T> target)
     throws IncompatibleTypeException {
   final int n = source.numDimensions();
   final double[] s = new double[n];
   for (int d = 0; d < n; ++d) s[d] = sigma;
   gauss(s, source, target);
 }
Ejemplo n.º 2
0
 @Override
 public void run() {
   double[] sigmas = sigmas();
   @SuppressWarnings("unchecked")
   Img<T> target = (Img<T>) dataset.getImgPlus();
   Img<T> input = target.copy();
   ExtendedRandomAccessibleInterval<T, ?> paddedInput = Views.extendMirrorSingle(input);
   try {
     Gauss3.gauss(sigmas, paddedInput, target);
   } catch (Exception e) {
     cancel(e.getMessage());
   }
 }
Ejemplo n.º 3
0
  private boolean processSlice(
      final RandomAccessibleInterval<FloatType> src,
      final RandomAccessibleInterval<FloatType> dx,
      final RandomAccessibleInterval<FloatType> dy) {
    // Gaussian filter.
    final ExtendedRandomAccessibleInterval<FloatType, RandomAccessibleInterval<FloatType>>
        extended = Views.extendMirrorSingle(src);
    try {
      Gauss3.gauss(new double[] {sigma, sigma}, extended, src, numThreads);
    } catch (final IncompatibleTypeException e) {
      errorMessage = BASE_ERROR_MSG + "Incompatible types: " + e.getMessage();
      e.printStackTrace();
      return false;
    }

    // Derivatives
    PartialDerivative.gradientCentralDifference(extended, dx, 0);
    PartialDerivative.gradientCentralDifference(extended, dy, 1);

    return true;
  }