private void equalsTranVertical(
      WaveletDescription<?> desc,
      ImageSingleBand input,
      ImageSingleBand expected,
      ImageSingleBand found) {
    int w = expected.width;
    int h = expected.height;

    int lowerBorder = UtilWavelet.borderForwardLower(desc.getInverse().getInnerCoefficients());
    int upperBorder =
        input.height
            - UtilWavelet.borderForwardUpper(
                desc.getInverse().getInnerCoefficients(), input.height);

    equalsTranVertical(
        expected.subimage(0, 0, w, h / 2),
        found.subimage(0, 0, w, h / 2),
        lowerBorder / 2,
        upperBorder / 2,
        "top");
    equalsTranVertical(
        expected.subimage(0, h / 2, w, h),
        found.subimage(0, h / 2, w, h),
        lowerBorder / 2,
        upperBorder / 2,
        "bottom");
  }
  /**
   * Compares two wavelet transformations while ignoring the input image borders. Input borders
   * affect the borders of internal segments inside the transformation.
   */
  private void equalsTranHorizontal(
      WaveletDescription<?> desc,
      ImageSingleBand input,
      ImageSingleBand expected,
      ImageSingleBand found) {
    int w = expected.width;
    int h = expected.height;

    int lowerBorder = UtilWavelet.borderForwardLower(desc.getInverse().getInnerCoefficients());
    int upperBorder =
        input.width
            - UtilWavelet.borderForwardUpper(desc.getInverse().getInnerCoefficients(), input.width);

    equalsTranHorizontal(
        expected.subimage(0, 0, w / 2, h),
        found.subimage(0, 0, w / 2, h),
        lowerBorder / 2,
        upperBorder / 2,
        "left");
    equalsTranHorizontal(
        expected.subimage(w / 2, 0, w, h),
        found.subimage(w / 2, 0, w, h),
        lowerBorder / 2,
        upperBorder / 2,
        "right");
  }
  public static void applyInnerMethod(
      String functionName,
      WaveletDescription<?> desc,
      ImageSingleBand input,
      ImageSingleBand output) {

    Method m;
    Object args[];
    if (functionName.contains("Inverse")) {
      WlCoef coef = desc.getInverse().getInnerCoefficients();
      m =
          BoofTesting.findMethod(
              ImplWaveletTransformInner.class,
              functionName,
              coef.getClass(),
              input.getClass(),
              output.getClass());
      args = new Object[] {coef, input, output};
    } else {
      WlCoef coef = desc.getForward();
      m =
          BoofTesting.findMethod(
              ImplWaveletTransformInner.class,
              functionName,
              coef.getClass(),
              input.getClass(),
              output.getClass());
      args = new Object[] {coef, input, output};
    }

    try {
      m.invoke(null, args);
    } catch (InvocationTargetException e) {
      throw new RuntimeException(e);
    } catch (IllegalAccessException e) {
      throw new RuntimeException(e);
    }
  }