MATLAB中的涟漪效应 [英] Ripple effect in MATLAB

查看:45
本文介绍了MATLAB中的涟漪效应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个函数 newim =波纹im(im),该函数获取图像并返回具有波纹效果的新图像.

I want to write a function newim = rippleim(im) that takes an image and returns a new image with ripple effect on it.

我认为计算距(p,q)的所有点的距离,然后乘以 sin(d).* exp(-d)会得到一个衰减效果好.

I thought calculating the distance of all points from (p,q) and then a multiplication of sin(d).*exp(-d) would give a good effect of fading waves.

n = 800;
m = 800;
im = zeros(n,m,3);
p = [round(m*.5) round(n*.5)];
[x y] = meshgrid(1:m,1:n);
x = x - p(1,1);
y = y - p(1,2);
d = (x .^2 + y .^2).^.5;
R = cos(.05*d) .* exp(-.005*d);
G = cos(.05*d) .* exp(-.005*d);
B = cos(.05*d) .* exp(-.005*d);
im = cat(3,R,G,B);
imshow(im);

我知道了

归一化为 [0 1] ,它会好一点,

with normalization to [0 1], it got a little better,

它似乎仍然不正确.

我什至在Google上搜索Google动画,并在python 此处中发现了一些类似的情况.但是我只想要一个固定的效果.

I even googled and found some similar cases in python here, about the animation. But I just want a fixed effect.

第一季度如何提高效果?

第二季度如何将其应用于现有图像?

Q2 How to apply it on an existing image?

谢谢

推荐答案

我终于找到了答案.我要找的东西可以通过 warp 命令完成.

I finally found my answer. What I was looking for, can be done by warp command.

因此,我借助 cos(d)* exp(-d)定义3D波纹表面,并在其上纹理我的图片.

so I define a 3D rippled surface with help of cos(d)*exp(-d) and texture my picture on it.

im = imread('peppers.png');
n = -10 : .1 : 10;
[X,Y] = meshgrid(n,n);
d = (X .^ 2 + Y .^ 2) .^ .5;
Z = cos(1.5 * d) .* exp(-.1 .* d);
warp(X,Y,Z,im);axis equal;axis off;

这篇关于MATLAB中的涟漪效应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆