Set a specific spatial frequency for my Guassian generated dots

3 Ansichten (letzte 30 Tage)
Hello! I am fairly new to Matab and I am stuggling with including a specific spatial frequency for my dot pattern.I need to generate polka dot patterns using either sine waves or gassian function with a specific satial frequency. I decided to use Gaussian funtion. In the code below, I am generating random dots using the Gaussian function. I need my dots to have a specific spatial frequency so that I can divide my pictures into low spatial frequncy and high spatial frequncy groups. But I am struggling to figure out how to do that. Any help/tips is much appreciated.
N=560;
nDots = 5;
s=25;
[x,y]=meshgrid(1:N,1:N);
xc=rand(nDots,1)*N
xc = 5×1
59.3940 530.3383 143.4087 60.1356 545.9591
yc=rand(nDots,1)*N
yc = 5×1
96.8866 528.8498 375.8636 334.4373 52.0325
val=zeros(N)
val = 560×560
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
for k=1:nDots
r2=(x-xc(k)).^2 + (y-yc(k)).^2;
val = val + exp(-r2 / (2*s^2));
end
imagesc(val);
colormap gray;
axis equal;
axis off;

Akzeptierte Antwort

Mathieu NOE
Mathieu NOE am 12 Apr. 2023
hello
maybe this ?
now you can specify the x and y direction spacing with dx and dy (the total number of points is constant) . You can actually see that the picture gets bigger if you increase dx and dy
you may want to use the same value for both dx and dy for simplification
N=560;
nDots = 5;
s=25;
% spatial spacing
dx = 0.25;
dy = 0.5;
s=25*norm(dx,dy); % correct s for non unity spatial spacing
x1 = dx*(1:N);
y1 = dy*(1:N);
[X,Y]=meshgrid(x1,y1);
xc=rand(nDots,1)*N*dx;
yc=rand(nDots,1)*N*dy;
val1=zeros(N);
for k=1:nDots
r2=(X-xc(k)).^2 + (Y-yc(k)).^2;
val1 = val1 + exp(-r2 / (2*s^2));
end
figure(1);
imagesc(x1,y1,val1);
colormap gray;
axis equal;
% axis off;
  2 Kommentare
Gelareh
Gelareh am 15 Apr. 2023
Dear Mathieu
Thank you for your answer. I need all my dots to have a certain spatial frequnecy. By divinding my pictures to low and high satial frequency I meant the dots. Thanks!
Mathieu NOE
Mathieu NOE am 19 Apr. 2023
If my nswer has helped you, do you mean accepting it ?
thanks

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by