Ripple effect in MATLAB
问题 I want to write a function newim = rippleim(im) that takes an image and returns a new image with ripple effect on it. 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) .