下采样downsamp和上采样upsample
图像的上采样(up-sampling)和下采样(down-sampling)
缩小图像(或称为下采样(subsampled)或降采样(downsampled)的主要目的有两个:
1.使得图像符合显示区域的大小,
2生成对应图像的缩略图.
放大图像(或称为上采样(upsampling)或图像插值(interpolating)的主要目的是放大原图像,从而可以显示在更高分辨率的显示设备上,对图像的缩放操作并不能带来更多关于该图像的信息,因此图像的质量将不可避免地受到影响.然而,确实有一些缩放方法能够增加图像的信息,从而使得缩放厚的图像质量超过原图质量的.
上采样原理:图像放大几乎都是采用内插值方法,即在原有图像像素的基础上在像素点之间采用合适的插值算法插入新的元素.
为什么要进行上采样?
上采样是为了将特征图采样到指定分辨率大小,比如一张(416,416,3)的图片经过一系列卷积池化操作后,得到一个特征图,维度(13,13,16), 为了把这个特征图和原图进行比较,需要将这个特征图变成(416,416,3)大小.这个就称为上采样.
上采样的过程类似于一个卷积的过程,只不过在卷积之前将输入特征值插到一个更大的特征图然后进行卷积,
在神经网络中,扩大特征图的方法,即upsample/上采样的方法
1)unpooling,恢复MAX的位置,其余部分补0
2)deconvolution(反卷积):先对input补零,再conv
3)插值方法,双线性插值等,
pytorch 有相应API:
torch.nn.UpsamplingBilinear2d(size=None,scale_factor=None)
#使用方法
class UnetUp_2(nn.Module):def __init__(self):self.up=nn.UpsamplingBilinear2d(scale_factor=(2,2))def forward(self, input):output=self.up(input)return output
- 对输入特征图进行上采样,
- 参数
- size - 输出尺寸,可以自己指定比如(512,418)
- scale_factor - 空间尺寸放大倍数
- 备注:size和scale_factor两个参数不能同时指定,只能指定一个
再来看其在tensorflow中的实现,可以看出,就是对输入图像做了一个resize()操作,
class UpSampling2D(_UpSampling):"""Upsampling layer for 2D inputs.Repeats the rows and columns of the databy size[0] and size[1] respectively.# Argumentssize: int, or tuple of 2 integers.The upsampling factors for rows and columns.data_format: A string,one of `"channels_last"` or `"channels_first"`.The ordering of the dimensions in the inputs.`"channels_last"` corresponds to inputs with shape`(batch, height, width, channels)` while `"channels_first"`corresponds to inputs with shape`(batch, channels, height, width)`.It defaults to the `image_data_format` value found in yourKeras config file at `~/.keras/keras.json`.If you never set it, then it will be "channels_last".interpolation: A string, one of `nearest` or `bilinear`.Note that CNTK does not support yet the `bilinear` upscalingand that with Theano, only `size=(2, 2)` is possible.# Input shape4D tensor with shape:- If `data_format` is `"channels_last"`:`(batch, rows, cols, channels)`- If `data_format` is `"channels_first"`:`(batch, channels, rows, cols)`# Output shape4D tensor with shape:- If `data_format` is `"channels_last"`:`(batch, upsampled_rows, upsampled_cols, channels)`- If `data_format` is `"channels_first"`:`(batch, channels, upsampled_rows, upsampled_cols)`"""@interfaces.legacy_upsampling2d_supportdef __init__(self, size=(2, 2), data_format=None, interpolation='nearest',**kwargs):normalized_size = conv_utils.normalize_tuple(size, 2, 'size')super(UpSampling2D, self).__init__(normalized_size, data_format, **kwargs)if interpolation not in ['nearest', 'bilinear']:raise ValueError('interpolation should be one ''of "nearest" or "bilinear".')self.interpolation = interpolationdef call(self, inputs):return K.resize_images(inputs, self.size[0], self.size[1],self.data_format, self.interpolation)def get_config(self):config = super(UpSampling2D, self).get_config()config['interpolation'] = self.interpolationreturn config
下采样downsamp和上采样upsample相关推荐
- 一个不限制插值个数和上采样倍数的视频增强方法
作者单位:麦克马斯特大学 论文:https://arxiv.org/pdf/2102.13011.pdf 看点 近年来,大量的视频增强研究致力于同时提高时间帧速率和空间分辨率,这些方法要么不能揭示时空 ...
- 降采样和上采样(图像)
https://blog.csdn.net/u013146742/article/details/51865522 降采样 又名 下采样或缩小图像.即是采样点数减少.对于一幅N*M的图像来说,如果降采 ...
- PCL点云曲面重采样三种方法:上采样,下采样,均匀采样
(1)下采样 Downsampling 一般下采样是通过构造一个三维体素栅格,然后在每个体素内用体素内的所有点的重心近似显示体素中的其他点,这样体素内所有点就用一个重心点来表示,进行下采样的来达到滤 ...
- 上采样和下采样_OpenCV学习笔记(一)之图像金字塔-上采样与降采样与DOG
一. 图像金字塔 一个图像金字塔式一系列的图像组成,最底下的图形尺寸最大,最上方的图像尺寸最小. 高斯金字塔是从底向上,逐层降采样得到的. 高斯金字塔的生成过程分为两步: 对当前层进行高斯模糊. 删除 ...
- 过采样与欠采样图像重采样(上采样下采样)
参考文章: https://blog.csdn.net/majinlei121/article/details/46742339 https://blog.csdn.net/Chaolei3/arti ...
- 上采样,重采样和下采样,降采样
一.上采样(重采样) 1.上采样就是重采样也就是放大图像,通常使用的目的是 (1)使图片达到更高的分辨率 (2)再经过pooling后上采样可以放大信息,循环迭代可以不断增强有用信息 2. 上采样原理 ...
- 数据预处理--上采样(过采样)与下采样(降采样)
Imblearn package study 1. 准备知识 1.1 Compressed Sparse Rows(CSR) 压缩稀疏的行 2. 过采样(Over-sampling) 2.1 实用性的 ...
- 彻底分清机器学习中的上采样、下采样、过采样、欠采样【总结】
今天看了篇中文的硕士论文,读着读着感觉有点奇怪,仔细一看原来他把下采样和欠采样搞混了,这里笔者就详细区分一下各个名称的概念. 文章目录 1. 上采样&下采样 2.过采样&欠采样 3.信 ...
- 降采样,过采样,欠采样,子采样,下采样,上采样,你学会了吗?【总结】
降采样: 2048HZ对信号来说是过采样了,事实上只要信号不混叠就好(满足尼奎斯特采样定理),所以可 以对过采样的信号作抽取,即是所谓的"降采样". 在现场中采样往往受具体条件的限 ...
最新文章
- 【SLAM】卡尔曼滤波:究竟滤了谁?
- 动手学深度学习需要这些数学基础知识
- 运行程序报“应用程序配置不正确”或者缺少运行库造成程序不可移植的问题...
- 返回Json数据浏览器带上<pre></pre>标签解决方法
- leetcode算法题--推多米诺
- Linux下挂载存储设备
- 毛笔笔锋算法IOS版
- git常用命令流程图
- 控制台发送get命令_.NET Core使用命令行参数库构建控制台应用程序
- 653B. Bear and Compressing
- Flutter MaterialButton组件详细概述
- 输入法全屏_五笔输入法那么方便,为什么败给了拼音?如今,我可算是明白了...
- 解读 SSDB、LevelDB 和 RocksDB 到 GaussDB(for Redis) 的迁移
- 跨语言调用模块.TXT
- Java学习教程,Java基础教程(入门到精通)
- win10磁盘管理_win10合并磁盘分区教程
- Oracle锁机制深度分析
- 从偏差和方差的角度解释bagging和boosting的原理
- 数据分析 -- Pandas①
- 账单分期和最低还款之间的差距你绝对想不到,以广发卡为例子,看看自动分期的好处。