我正在寻找一种比使用GaussianBlur更快的模糊图像的方法。
我正在寻找的解决方案可以是命令行解决方案,但我更喜欢使用 perl 表示法的代码。
实际上,我们使用 Perl image magick API 来模糊图像:
# $image is our Perl object holding a imagemagick perl image
# level is a natural number between 1 and 10
$image->GaussianBlur('x' . $level);
这工作得很好,但随着关卡高度的增加,它消耗的时间似乎呈指数级增长。
问题:如何缩短模糊操作所用的时间? 还有另一种更快的方法来模糊图像吗?
最佳答案
我发现the suggested method调整图像大小以进行模糊模仿会使输出看起来非常像素化,因为西格玛值非常大,例如 25 或更大。所以我最终想到了缩小-模糊-放大的想法,这产生了非常好的结果(几乎与大西格玛的简单模糊没有区别):
# plain slow blur
convert -blur 0x25 sample.jpg blurred_slow.jpg
# much faster
convert -scale 10% -blur 0x2.5 -resize 1000% sample.jpg blurred_fast.jpg
在我的 i5 2.7Ghz 上,速度提升高达 10 倍。
关于perl - ImageMagick:寻找一种快速模糊图像的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35649413/