所以我试图对使用 Java 的图像应用高斯滤波器。然而,图像根本不受过滤器的影响。我正在使用内置的卷积运算符。有人能指出我出了什么问题吗?
public static void main(String[] args) {
File img = new File( "C:\\Users\\Aditya\\Pictures\\20130729_140153.jpg" );
BufferedImage a = null;
try{
a= ImageIO.read( img );
}
catch( Exception e ){
System.out.print( e.toString() );
return;
}
BufferedImage a9 = new BufferedImage( a.getWidth() , a.getHeight() , a.getType() );
float[] matrix = {
1f/273,4f/273,7f/273,4f/273,1f/273,
4f/273,16f/273,26f/273,16f/273,4f/273,
7f/273,26f/273,41f/273,26f/273,7f/273,
4f/273,16f/273,26f/273,16f/273,4f/273,
1f/273,4f/273,7f/273,4f/273,1f/273
};
BufferedImageOp op = new ConvolveOp( new Kernel( 5, 5, matrix ) );
a9 = op.filter( a, a9 );
try{
ImageIO.write( a9 , "jpg" ,new File( "C:\\Users\\Aditya\\Pictures\\jim.jpg" ));
}catch( Exception e ){
System.out.println( e );
}
}
}
不工作是指a和a9的图像根本没有区别。就好像他们被复制了一样!