- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我想扩充 MNIST 手写数字数据集。
为此,我想为每个图像分别创建一个弹性变形图像。
我阅读了this论文,第 2 节“通过 Elastic 扩展数据集”扭曲'他们完成了弹性扭曲
之前:
之后:
我试过:
http://www.mathworks.com/help/images/ref/imwarp.html http://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 (?) not quite sure about this "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');
最后阶段 - 使用 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
顺便说一句,我不确定建议的方法 (rand
+imfilter
) 是产生随机平滑变形的最直接的方法,您可以考虑采样2 次或 3 次多项式变形系数,
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;
关于image - 展开 MNIST - 弹性变形 MATLAB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39308301/
我正在尝试在我的网站上嵌入多个 .svg 文件。只要我使用 Chrome、Firefox 或我目前测试过的任何移动浏览器,一切似乎都运行良好。但是,有一个异常(exception):每当我在 Wind
我正在尝试在我的网站上嵌入多个 .svg 文件。只要我使用 Chrome、Firefox 或我目前测试过的任何移动浏览器,一切似乎都运行良好。但是,有一个异常(exception):每当我在 Wind
是否有某种方法(库或算法)可用于在 java.awt.Shape 或其路径迭代器的两个实例之间进行插值?例如,要在矩形和椭圆之间无缝过渡?或者更一般的 Path2D 情况。 最佳答案 SwingX 中
我试图在动态大小的视频上包含一个 Canvas 元素,该视频将异步加载。在 Canvas 上,用户将能够拖动矩形选择框并调整其大小。 在我的 JS 文件中,我有一个监听器监 window 口,并通过
Closed. This question needs to be more focused。它当前不接受答案。 想改善这个问题吗?更新问题,使其仅关注editing this post一个问题。 去
有没有办法通过 GDAL(使用 Python API)使用移位向量来扭曲图像? 通过移位向量,我的意思是例如。包含以下列的 CSV(或 numpy)文件:starting_x,starting_y,t
我正在创建一个导航按钮。当用户按下它时,按钮的图像应该改变,反射(reflect)它的状态(例如菜单打开/关闭)。我决定为此做一个 morphing-liek 动画。可以用CoreAnimation来
我在 Pandas 中有以下示例数据框。如何获取每个 'Id' 的 'label_weight' 值的最大值并将相应的 'label' 列分配给该 'Id' 在新列 'assgined_label'
文本使我的框变形。 这是我的: This text is deforming the "leftOne" 还有 CSS: .leftOne { float: left;
HTML: Home Services About Us Contact Us CSS: ul { pa
我想在这里得到 openCV 爱好者的帮助。 我想知道关于如何变形 2 个面孔的方向(以及一些建议或代码段),以及一种比率,即第一个面孔的 10% 和第二个面孔的 90%。 我见过像 cvWarpAf
我已经搜索了很长时间,但还没有找到真正的答案,但是,也许我的眼睛上有西红柿,但是真的没有针对 python/MATLAB 的框架可以进行面部扭曲/开箱即用? 一个框架,我在其中放入两张带有特征点的图像
根据material.io float 操作按钮可以变身为操作菜单,如 this .有什么方法可以只使用 Material 库(没有第三方库)吗? 我试过了this库,但它会在菜单关闭后根据底部应用栏
这就是我想用我的 NSOpenGLView 做的事情。目前 NSOpenGLView 覆盖了窗口的整个区域,我想在 NSOpenGLView 顶部添加按钮、nsviews 和图像。我浏览了网页,发现
我正在遍历在 Controller 中定义的集合。 我正在使用基础轨道插件将其转变为轮播。 但是我的HTML被弄乱了,并且破坏了插件,因为它期望获得一定的输出。
我不知道如何使用 BufferedImage 使图像变形。有人能帮我吗 ?我绝对绝望了。感谢您的所有提示。对不起我的英语不好。 | |
这个问题的答案似乎相互矛盾,我很困惑在 Core Data 数据库中存储图像的最佳方式是什么。 This question说可变形,但是this question说要使用二进制数据。 如果我只是想把它
您好,我不确定如何处理有关表单的逻辑。所以,表格很大,我知道有 20 多个字段被认为是“不好的做法”,表格应该最少,但这就是客户想要的,所以不用争论,无论如何表格都会接受订单,但有不同的顺序类型(更具
我正在使用 animator() 在我的应用程序的帧( subview )之间横向滚动 NSScrollView。当动画发生并且我调整 NSWindow 的大小时,整个 NSView 会像这样扭曲:
仍在我的太空入侵者克隆上工作,我想在屏幕底部添加可破坏的基地: 我已经弄清楚如何通过让炸弹和盾牌相互接触来修改盾牌的外观,然后在 didBegincontact 中,从炸弹爆炸的 mask 和盾牌的当
我是一名优秀的程序员,十分优秀!