How to create ripples on the image

11 ビュー (過去 30 日間)
kumara dommeti
kumara dommeti 2020 年 7 月 21 日
コメント済み: kumara dommeti 2020 年 7 月 29 日
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.
kumara dommeti
kumara dommeti 2020 年 7 月 29 日
May be modification in the code given in the link below (fft_filter.m) will be useful?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImage Segmentation and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by