/** * Raises each pixel in the input image to the power of two. Both the input and output image can be the same * instance. * * @param input The input image. Not modified. * @param output Where the pow2 image is written to. Modified. */ public static <T extends ImageBase<T>> void pow2(T input , T output ) { if( input instanceof ImageGray ) { if (GrayF32.class == input.getClass()) { PixelMath.pow2((GrayF32) input, (GrayF32) output); } else if (GrayF64.class == input.getClass()) { PixelMath.pow2((GrayF64) input, (GrayF64) output); } else { throw new IllegalArgumentException("Unknown image Type: " + input.getClass().getSimpleName()); } } else if( input instanceof Planar ) { Planar in = (Planar)input; Planar out = (Planar)output; for (int i = 0; i < in.getNumBands(); i++) { pow2( in.getBand(i), out.getBand(i)); } } }
public void zeroMeanStdOne( int radius , T input , double maxPixelValue , double delta , T output ) { // check preconditions and initialize data structures initialize(input, output); // avoid overflow issues by ensuring that the max pixel value is 1 T adjusted = ensureMaxValueOfOne(input, maxPixelValue); // take advantage of 2D gaussian kernels being separable if( border == null ) { GBlurImageOps.mean(adjusted, localMean, radius, output); GPixelMath.pow2(adjusted, pow2); GBlurImageOps.mean(pow2, localPow2, radius, output); } else { throw new IllegalArgumentException("Only renormalize border supported here so far. This can be changed..."); } // Compute the final output if( imageType == GrayF32.class ) computeOutput((GrayF32)input, (float)delta, (GrayF32)output, (GrayF32)adjusted); else computeOutput((GrayF64)input, delta, (GrayF64)output, (GrayF64)adjusted); }
public void zeroMeanStdOne(Kernel1D kernel, T input , double maxPixelValue , double delta , T output ) { // check preconditions and initialize data structures initialize(input, output); // avoid overflow issues by ensuring that the max pixel value is 1 T adjusted = ensureMaxValueOfOne(input, maxPixelValue); // take advantage of 2D gaussian kernels being separable if( border == null ) { GConvolveImageOps.horizontalNormalized(kernel, adjusted, output); GConvolveImageOps.verticalNormalized(kernel, output, localMean); GPixelMath.pow2(adjusted, pow2); GConvolveImageOps.horizontalNormalized(kernel, pow2, output); GConvolveImageOps.verticalNormalized(kernel, output, localPow2); } else { GConvolveImageOps.horizontal(kernel, adjusted, output, border); GConvolveImageOps.vertical(kernel, output, localMean, border); GPixelMath.pow2(adjusted, pow2); GConvolveImageOps.horizontal(kernel, pow2, output, border); GConvolveImageOps.vertical(kernel, output, localPow2, border); } // Compute the final output if( imageType == GrayF32.class ) computeOutput((GrayF32)input, (float)delta, (GrayF32)output, (GrayF32)adjusted); else computeOutput((GrayF64)input, delta, (GrayF64)output, (GrayF64)adjusted); }