How to create ripples on the image

11 visualizzazioni (ultimi 30 giorni)
kumara dommeti
kumara dommeti il 21 Lug 2020
Commentato: kumara dommeti il 29 Lug 2020
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?

Risposte (1)

Gouri Chennuru
Gouri Chennuru il 24 Lug 2020
Modificato: Gouri Chennuru il 24 Lug 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.
Bsxfun is used here for element wise multiplication between the mask im and the image imp.
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 !
  2 Commenti
kumara dommeti
kumara dommeti il 25 Lug 2020
When I implement this code, the intensities in the background are varying widely. But I need to consider a background which is like in the Sonar images and as the images are intensity images, they represent 2-D images.

Accedi per commentare.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by