How can I make a set of stimuli composed of pseudorandom dots of the same size and each stimuli having different spatial frequencies/densities?

1 view (last 30 days)
I'd like to generate 50 stimuli composed of pseudorandom dots of the same size and each stimulus having different spatial frequencies/densities? I think I need to use stochastic screening based on my google searches but I don't know how to generate them. The picture attached is from wikipedia. I'd like to generate something similiar to the smaller squares where we can see how each is increasing in sptial frequency.
Thank you for your help!
Refernce: https://en.wikipedia.org/wiki/Stochastic_screening

Answers (1)

chicken vector
chicken vector on 19 Apr 2023
Edited: chicken vector on 19 Apr 2023
This is slow and inefficient and can be improven with more pseudo-random techniques, but it does the tricks:
% Dots size:
dotSize = 5;
% Numbers density variations along 'x':
xSize = 1e3;
% Number of dots at first and last x:
minDots = 1;
maxDots = 1000;
% Dots interpolation:
nDots = linspace(minDots, maxDots, xSize);
% Initiliase figure:
figure;
hold on;
% loop over x coordinates:
for x = 1 : xSize
% Number of dots at current 'x':
numEl = round(nDots(x));
% Create 'x' noise:
noise = rand(numEl, 1) - .5;
% Plot dots at current 'x':
scatter(x + noise, rand(1,numEl), dotSize, 'k', 'Filled');
end
% Figure properties:
xlim([0, xSize])
ylim([0, 1])
set(gca, 'Color', 'w', 'XColor', 'None', 'YColor', 'None')
Result:

Categories

Find more on Entering Commands in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!