How to create ripples on the image

14 次查看(过去 30 天)
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?

回答(1 个)

Gouri Chennuru
Gouri Chennuru 2020-7-24
编辑:Gouri Chennuru 2020-7-24
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 个评论
kumara dommeti
kumara dommeti 2020-7-25
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Image Segmentation and Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by