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 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