close all;
clear;
PsychDefaultSetup(2);
matdemopath = [PsychtoolboxRoot 'PsychDemos/OpenGL4MatlabDemos/mogldemo.mat'];
load(matdemopath, 'face');
FreqPeak = [8 32 128];
FreqSigma = Inf;
ThetaPeak = (0:45:135) .* pi/180;
ThetaSigma = 10 .* pi/180;
origFace = face{1};
[res]= DoLogGabor(origFace, FreqPeak, FreqSigma, ThetaPeak, ThetaSigma);
[s1, s2, s3, s4] = size(res);
numImages = s3 * s4;
freqPeaksLine = sort(repmat(FreqPeak, 1, s4));
thetaPeaksLine = repmat(ThetaPeak, 1, s3);
screens = Screen('Screens');
screenNumber = max(screens);
white = WhiteIndex(screenNumber);
black = BlackIndex(screenNumber);
grey = white / 2;
inc = white - grey;
darkGrey = white * 0.25;
[window, windowRect] = PsychImaging('OpenWindow', screenNumber, darkGrey, [], 32, 2);
[screenXpixels, screenYpixels] = Screen('WindowSize', window);
ifi = Screen('GetFlipInterval', window);
[xCenter, yCenter] = RectCenter(windowRect);
Screen('BlendFunction', window, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA');
Screen('TextSize', window, 30);
imageTexture = nan(1, numImages);
thisIm = 0;
for i = 1:s3
for j = 1:s4
thisIm = thisIm + 1;
thisImage = real(res(:, :, i, j));
imageMin = min(thisImage(:));
rangeImage = max(thisImage(:)) - imageMin;
thisImageNorm = (thisImage - imageMin) / rangeImage;
imageTexture(thisIm) = Screen('MakeTexture', window, thisImageNorm);
end
end
origFaceNorm = (origFace - min(origFace(:))) / (max(origFace(:)) - min(origFace(:)));
imageTextureFace = Screen('MakeTexture', window, origFaceNorm);
scaleFactor = 2;
baseRect = [0 0 s1 s2];
scaledRect = baseRect .* 2;
leftRect = CenterRectOnPointd(scaledRect, screenXpixels * 0.25, screenYpixels / 2);
rightRect = CenterRectOnPointd(scaledRect, screenXpixels * 0.75, screenYpixels / 2);
bothRects = [leftRect; rightRect];
changeFrame = round(1 / ifi);
faceTicker = 0;
imageToShow = 1;
textBoundsOrig = Screen('TextBounds', window, 'Original Image');
pixelsAboveImage = 10;
xLocOrig = screenXpixels * 0.25;
yLocOrig = (screenYpixels / 2) - (textBoundsOrig(4) / 2)...
- (s1 / 2 * scaleFactor) - pixelsAboveImage;
leftTextPos = CenterRectOnPointd(textBoundsOrig, xLocOrig, yLocOrig);
textBoundsFilt = Screen('TextBounds', window, 'Filtered Image');
pixelsAboveImage = 10;
xLocOrig = screenXpixels * 0.75;
yLocOrig = (screenYpixels / 2) - (textBoundsFilt(4) / 2)...
- (s1 / 2 * scaleFactor) - pixelsAboveImage;
rightTextPos = CenterRectOnPointd(textBoundsFilt, xLocOrig, yLocOrig);
waitframes = 1;
vbl = Screen('Flip', window);
while ~KbCheck
Screen('DrawTextures', window,...
[imageTextureFace imageTexture(imageToShow)], [], bothRects', 0);
DrawFormattedText(window, 'Original Image',...
leftTextPos(1), leftTextPos(2), white);
DrawFormattedText(window, 'Filtered Image',...
rightTextPos(1), rightTextPos(2), white);
DrawFormattedText(window, ['Filter Parameters\n\n Frequency-Peak '...
num2str(freqPeaksLine(imageToShow))...
', Frequency-Sigma ' num2str(FreqSigma)...
', Theta-Peak ' num2str(thetaPeaksLine(imageToShow))...
', Theta-Sigma ' num2str(ThetaSigma)],...
'center', screenYpixels * 0.8, white);
vbl = Screen('Flip', window, vbl + (waitframes - 0.5) * ifi);
faceTicker = faceTicker + 1;
if faceTicker == 60
imageToShow = imageToShow + 1;
if imageToShow > numImages
imageToShow = 1;
end
faceTicker = 0;
end
end
sca