扩展MNIST – MATLAB中的弹性变形

我想增强MNIST手写数字数据集。
为此,我希望为每张图像分别创建一个弹性变形图像。

我在这篇论文的第2节“通过弹性变形扩展数据集”中读到,他们实现了弹性变形

之前:

enter image description here

之后:

enter image description here

我尝试过:

http://www.mathworks.com/help/images/ref/imwarp.htmlhttp://www.mathworks.com/help/images/examples/creating-a-gallery-of-transformed-images.html

但没有成功。

如何在MATLAB中实现这一点?

如何在MATLAB中对图像进行弹性变形转换?


回答:

我不是很确定完全理解了位移场的“归一化”方法,但我认为这可以让你非常接近

img = imread('http://deeplearning.net/tutorial/_images/mnist_2.png');  %// get a digit

计算随机位移场 dx~U(-1,1), dy~U(-1,1)

dx = -1+2*rand(size(img)); dy = -1+2*rand(size(img)); 

平滑和归一化字段:

sig=4; alpha=60;H=fspecial('gauss',[7 7], sig);fdx=imfilter(dx,H);fdy=imfilter(dy,H);n=sum((fdx(:).^2+fdy(:).^2)); %// norm (?) 不确定这个“norm”fdx=alpha*fdx./n;fdy=alpha*fdy./n;

结果位移

[y x]=ndgrid(1:size(img,1),1:size(img,2));figure;imagesc(img); colormap gray; axis image; axis tight;hold on;quiver(x,y,fdx,fdy,0,'r');

enter image description here

最后阶段 – 使用griddata插值将位移应用于实际像素:

new = griddata(x-fdx,y-fdy,double(img),x,y);new(isnan(new))=0;

结果数字:

figure;subplot(121); imagesc(img); axis image;subplot(122); imagesc(new); axis image;colormap gray

enter image description here


顺便说一句,我不确定提出的方法(rand+imfilter)是产生随机平滑变形的最直接方法,你可以考虑采样二次或三次多项式变形的系数,

dx = a*x.^2 + b*x.*y + c*y.^2 + d*x + e*y + f;dy = g*x.^2 + h*x.*y + k*y.^2 + l*x + m*y + n;

Related Posts

L1-L2正则化的不同系数

我想对网络的权重同时应用L1和L2正则化。然而,我找不…

使用scikit-learn的无监督方法将列表分类成不同组别,有没有办法?

我有一系列实例,每个实例都有一份列表,代表它所遵循的不…

f1_score metric in lightgbm

我想使用自定义指标f1_score来训练一个lgb模型…

通过相关系数矩阵进行特征选择

我在测试不同的算法时,如逻辑回归、高斯朴素贝叶斯、随机…

可以将机器学习库用于流式输入和输出吗?

已关闭。此问题需要更加聚焦。目前不接受回答。 想要改进…

在TensorFlow中,queue.dequeue_up_to()方法的用途是什么?

我对这个方法感到非常困惑,特别是当我发现这个令人费解的…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注