Set a specific spatial frequency for my Guassian generated dots
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
yc=rand(nDots,1)*N
val=zeros(N)
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;
0 commentaires
Réponse acceptée
Mathieu NOE
le 12 Avr 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Distribution Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
