-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbars.m
30 lines (24 loc) · 842 Bytes
/
bars.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
imgSize=[3000 3000];
freq=[12,25,50,100,250]; %pixels
angleIncrement=30; %degrees
saveFolder='C:\Users\sther\Pictures\gratings';
for f=1:numel(freq)
currFreq=freq(f);
whiteIndices=1:currFreq/2:imgSize(2);
whiteIndices=whiteIndices(1:2:end);
whiteOn=whiteIndices(1:2:end);
whiteOff=whiteIndices(2:2:end);
if length(whiteOn)>length(whiteOff)
whiteOff(end+1)=imgSize(2);
end
img=uint8(zeros(imgSize));
for bar=1:length(whiteOn)
img(:,whiteOn(bar):whiteOff(bar))=255;
end
for angle=angleIncrement:angleIncrement:180
imgR = imrotate(img,angle,'crop') ;
%imshow(imgR(1000:2000,1000:2000))
filename=[saveFolder filesep 'grating_' num2str(angle) '_' num2str(currFreq) '.png'];
imwrite(imgR(1000:2000,1000:2000),filename)
end
end