How to create ripples on the image
10 views (last 30 days)
Show older comments
I have an intensity image like below. Now i have to create ripples on this image so that background looks like water (not exactly but similar). May be "fft" and "band pass filter" is used. But, how to create like that?
0 Comments
Answers (1)
Gouri Chennuru
on 24 Jul 2020
Edited: Gouri Chennuru
on 24 Jul 2020
Hi Kumara,
As a workaround, use this code to get the ripple effect to an image.
imp = double(imread('image.jpeg'));% image file name should be given
n = size(imp,1);
m = size(imp,2);
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).^.6;
mask = cos(.05*d) .* exp(-.005*d);
im = (mask-min(mask(:)))./ ( max(mask(:))-min(mask(:)));
I = bsxfun(@times,im,imp);
imshow(I/255);
Here we are trying to calculate the distance (d) of all points from p (which is the center of the image), and then create a mask which is a function of the calculated distance. This mask is then applied on the image which then create the effect of fading waves.
If in case you are trying for a 3-D rippled surface to an image you can execute the below code snippet.
In the case of 3-D, this effect can be easily achieved by using the wrap command.
im = imread('image.jpeg'); % input image file name
n = -10 : .1 : 10;
[X,Y] = meshgrid(n,n);
d = (X .^ 2 + Y .^ 2) .^ .5; % d = (X .^ 2 + Y .^ 2) .^ .6;
Z = cos(1.5 * d) .* exp(-.1 .* d);
warp(X,Y,Z,im);
axis equal;
axis off;
Hope this Helps !
See Also
Categories
Find more on Image Segmentation and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!