public static < T extends ImageBase < T > > void abs ( T input , T output ) { if ( input instanceof ImageGray ) { if ( GrayS8 . class == input . getClass ( ) ) { PixelMath . abs ( ( GrayS8 ) input , ( GrayS8 ) output ) ; } else if ( GrayS16 . class == input . getClass ( ) ) { PixelMath . abs ( ( GrayS16 ) input , ( GrayS16 ) output ) ; } else if ( GrayS32 . class == input . getClass ( ) ) { PixelMath . abs ( ( GrayS32 ) input , ( GrayS32 ) output ) ; } else if ( GrayS64 . class == input . getClass ( ) ) { PixelMath . abs ( ( GrayS64 ) input , ( GrayS64 ) output ) ; } else if ( GrayF32 . class == input . getClass ( ) ) { PixelMath . abs ( ( GrayF32 ) input , ( GrayF32 ) output ) ; } else if ( GrayF64 . class == input . getClass ( ) ) { PixelMath . abs ( ( GrayF64 ) input , ( GrayF64 ) output ) ; } // otherwise assume it is an unsigned image type } else if ( input instanceof ImageInterleaved ) { if ( InterleavedS8 . class == input . getClass ( ) ) { PixelMath . abs ( ( InterleavedS8 ) input , ( InterleavedS8 ) output ) ; } else if ( InterleavedS16 . class == input . getClass ( ) ) { PixelMath . abs ( ( InterleavedS16 ) input , ( InterleavedS16 ) output ) ; } else if ( InterleavedS32 . class == input . getClass ( ) ) { PixelMath . abs ( ( InterleavedS32 ) input , ( InterleavedS32 ) output ) ; } else if ( InterleavedS64 . class == input . getClass ( ) ) { PixelMath . abs ( ( InterleavedS64 ) input , ( InterleavedS64 ) output ) ; } else if ( InterleavedF32 . class == input . getClass ( ) ) { PixelMath . abs ( ( InterleavedF32 ) input , ( InterleavedF32 ) output ) ; } else if ( InterleavedF64 . class == input . getClass ( ) ) { PixelMath . abs ( ( InterleavedF64 ) input , ( InterleavedF64 ) output ) ; } } else { Planar in = ( Planar ) input ; Planar out = ( Planar ) output ; for ( int i = 0 ; i < in . getNumBands ( ) ; i ++ ) { abs ( in . getBand ( i ) , out . getBand ( i ) ) ; } } }
Sets each pixel in the output image to be the absolute value of the input image . Both the input and output image can be the same instance .