[英]Resizing data using cv2.imresize for neural network input
I have to scale down data to feed into a neural network . 我必须按比例缩小数据以馈入神经网络 。
I wanted to use cv2.imresize , but there are multiple options with regard to how it interpolates the data to scale it down: 我想使用cv2.imresize ,但是关于如何插值数据以按比例缩小它有多个选择:
Has anyone experimented with these, and if so what have you found? 有没有人尝试过这些,如果发现的话,您发现了什么? Note: I don't have enough time to try out learning with all varieties of interpolation. 注意:我没有足够的时间尝试学习各种插值方法。
For down sampling image data (I presume the data is an image since you're using OpenCV), you can just use area averaging to get good performance in terms of speed and quality (unless the downscaling factor is quite small, where blurring may happen). 对于向下采样的图像数据(由于您使用的是OpenCV,我认为数据是图像),您可以使用面积平均来获得速度和质量方面的良好性能(除非缩小比例很小,否则可能会发生模糊) )。
Nearest neighbor will drop some cells at regular intervals but will be quite fast since no interpolation is actually performed. 最近的邻居将以规则的时间间隔丢弃某些像元,但是由于实际上没有执行插值,因此会非常快。 However some aliasing is to be expected with most images. 但是,大多数图像都可能会有一些混叠 。
If quality is your main concern, use Lanczos (slower than bicubic, but higher quality images, generally speaking). 如果您最关心的是质量,请使用Lanczos (通常比双三次慢,但图像质量更高)。
Bicubic and bilinear are known to perform quite badly for downscaling images for factors less than 0.5. 已知双三次和双线性在缩小图像比例小于0.5时表现不佳。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.