예제 #1
0
 /**
  * General code for convolving a box filter across an image using the integral image.
  *
  * @param integral Integral image.
  * @param kernel Convolution kernel.
  * @param output The convolved image. If null a new image will be declared and returned. Modified.
  * @return Convolved image.
  */
 public static <T extends ImageSingleBand> T convolve(
     T integral, IntegralKernel kernel, T output) {
   if (integral instanceof ImageFloat32) {
     return (T) IntegralImageOps.convolve((ImageFloat32) integral, kernel, (ImageFloat32) output);
   } else if (integral instanceof ImageSInt32) {
     return (T) IntegralImageOps.convolve((ImageSInt32) integral, kernel, (ImageSInt32) output);
   } else {
     throw new IllegalArgumentException("Unknown input type");
   }
 }
예제 #2
0
 /**
  * Convolves a kernel around a single point in the integral image.
  *
  * @param integral Input integral image. Not modified.
  * @param kernel Convolution kernel.
  * @param x Pixel the convolution is performed at.
  * @param y Pixel the convolution is performed at.
  * @return Value of the convolution
  */
 public static <T extends ImageSingleBand> double convolveSparse(
     T integral, IntegralKernel kernel, int x, int y) {
   if (integral instanceof ImageFloat32) {
     return IntegralImageOps.convolveSparse((ImageFloat32) integral, kernel, x, y);
   } else if (integral instanceof ImageSInt32) {
     return IntegralImageOps.convolveSparse((ImageSInt32) integral, kernel, x, y);
   } else {
     throw new IllegalArgumentException("Unknown input type");
   }
 }
예제 #3
0
 /**
  * Converts a regular image into an integral image.
  *
  * @param input Regular image. Not modified.
  * @param transformed Integral image. If null a new image will be created. Modified.
  * @return Integral image.
  */
 public static <I extends ImageSingleBand, T extends ImageSingleBand> T transform(
     I input, T transformed) {
   if (input instanceof ImageFloat32) {
     return (T) IntegralImageOps.transform((ImageFloat32) input, (ImageFloat32) transformed);
   } else if (input instanceof ImageUInt8) {
     return (T) IntegralImageOps.transform((ImageUInt8) input, (ImageSInt32) transformed);
   } else if (input instanceof ImageSInt32) {
     return (T) IntegralImageOps.transform((ImageSInt32) input, (ImageSInt32) transformed);
   } else {
     throw new IllegalArgumentException("Unknown input type");
   }
 }