android.graphics.Bitmap.createScaledBitmap的声明是
public static Bitmap createScaledBitmap
(Bitmap src, int dstWidth, int dstHeight, boolean filter)
但是,文档没有解释任何参数。除了布尔过滤器之外,它们都很明显。有人知道它是做什么的吗?
android.graphics.Bitmap.createScaledBitmap的声明是
public static Bitmap createScaledBitmap
(Bitmap src, int dstWidth, int dstHeight, boolean filter)
但是,文档没有解释任何参数。除了布尔过滤器之外,它们都很明显。有人知道它是做什么的吗?
扩展一下Karan的回答:一般来说,如果你把图像缩小,你不会看到任何区别,但如果你把它放大,你会看到。
传入filter = false将产生块状、像素化的图像。
传递filter = true会给你更平滑的边缘。
然而,正如EIYeante在评论中指出的那样,你可能仍然会看到区别。这是他们的例子。
A quick dig through the SKIA source-code indicates that (at least by default) the FILTER flag causes it to do a straightforward bilinear interpolation. Check Wikipedia or your favorite graphics reference to see what the expected consequences are. Traditionally, you want to do bilinear or bicubic interpolation when upsizing images, and area averaging when downsizing images. I get the impression (though I'm glad to be corrected) that Android/Skia does simple subsampling when downsizing without filtering, so you are likely to get better results from filtering even when downsizing. (There's an alternate method for getting high quality downsizing with interpolation, involving doing a series of 50% scale reductions. See http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html for details.)
有点晚了,但我认为一些示例图像可以澄清这个问题。
还有一个更普遍的问题是关于是否以及如何过滤超级用户。
杰夫·阿特伍德说:
一般来说,当你把一张大图变成一张小图时,你想要一个温和的锐化效果,当你把一张小图变成一张大图时,你想要一个温和的模糊效果。
Android的API没有指定将应用哪种过滤器,所以我猜问题是:你想要你的像素保持原样(就像你想在8位艺术),还是可以应用一个转换,使图像更可口(就像你想在照片)。
在我的研究中,当filter=false时使用的算法(我需要100%确定产生的输出),因为我在android和python上使用相同的tensorflow lite模型,并发现当filter=false时它使用NEAREST(在android 7.1上测试)。我比较了在android和python上使用PIL resample=Image时相同的嵌入。最近的