private static void convolve2D ( GrayU8 gray ) { // By default 2D kernels will be centered around width/2 Kernel2D_S32 kernel = new Kernel2D_S32 ( 3 ) ; kernel . set ( 1 , 0 , 2 ) ; kernel . set ( 2 , 1 , 2 ) ; kernel . set ( 0 , 1 , - 2 ) ; kernel . set ( 1 , 2 , - 2 ) ; // Output needs to handle the increased domain after convolution. Can't be 8bit GrayS16 output = new GrayS16 ( gray . width , gray . height ) ; ImageBorder < GrayU8 > border = FactoryImageBorder . wrap ( BorderType . EXTENDED , gray ) ; GConvolveImageOps . convolve ( kernel , gray , output , border ) ; panel . addImage ( VisualizeImageData . standard ( output , null ) , "2D Kernel" ) ; }
Convolves a 2D kernel