This file is indexed.

/usr/share/psychtoolbox-3/PsychAlpha/ImageUndistortionDemo.m is in psychtoolbox-3-common 3.0.12.20160126.dfsg1-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
function ImageUndistortionDemo(calibfilename, imagefilename)
% ImageUndistortionDemo(calibfilename [, imagefilename])
%
% A very sketchy demo on how to do gpu accelerated geometric
% undistortion of images.
%
% 'calibfilename' Name of a calibration file, as also used by
% PsychImaging's 'GeometryCorrection' tasks, and generated by one
% of the available calibration procedures, e.g., DisplayUndistortionBVL,
% DisplayUndistortionCSV, DisplayUndistortionBezier, ...
%
% 'imagefilename' Optional name of image file to process. If left out,
% our standardy bunny image will be used. If set to 'checkerboard', a
% checkerboard pattern will be used.
%
% Press any key to exit the demo after the undistorted image was
% displayed.
%
% This demo is more a template for you to get started writing suitable
% code for your purpose than a ready made plug & play solution.
%

% History:
% 7/27/2008 mk Written.
% 7/25/2015 mk Updated.

% Basic check if runnning on PTB-3:
AssertOpenGL;

if nargin < 1 || isempty(calibfilename)
  error('Required calibfilename missing.');
end

if nargin < 2
  imagefilename = [];
end

if isempty(imagefilename)
  imagefilename = [PsychtoolboxRoot 'PsychDemos/konijntjes1024x768.jpg'];
end

% Choose output screen as usual:
screenid=max(Screen('Screens'));

% Only enable support for fast offscreen windows, don't need full blown pipeline here:
PsychImaging('PrepareConfiguration');
PsychImaging('AddTask', 'General', 'UseFastOffscreenWindows');
w=PsychImaging('OpenWindow', screenid, 0);

if ~strcmpi(imagefilename, 'checkerboard')
  % Use our standard bunny picture as some test case:
  img = imread(imagefilename);
else
  % Use a checkerboard pattern:
  [ww, wh] = Screen('WindowSize', w);
  checkSize = 105;
  img = 255 * double(checkerboard(checkSize,round(wh/checkSize/2),round(ww/checkSize/2)) > 0.5);
end

mytex=Screen('MakeTexture', w, img);

% Size of input image to apply correction to -- The size of the offscreen window:
srcSize = Screen('Rect', mytex);

% Setup oversized offscreen window: This as an example of an oversized
% input image buffer. Could also use a normal texture from
% Screen('MakeTexture') or any other function that returns texture handles:
[exampleImage, woffrect] = Screen('OpenOffscreenWindow', w, 0, srcSize);

% Create an offscreen window of the size of the wanted undistorted and
% scaled down image, as a target buffer:
undistortedImage = Screen('OpenOffscreenWindow', w, 128, srcSize);

% Create an empty image processing operator for onscreen window 'w':
gloperator = CreateGLOperator(w);

% Create and add image undistortion operation to gloperator:
% Setup calibration: 'calibfilename' is the path to the calibration file
% that defines undistortion and scaling: 73, 73 is resolution of warp-mesh,
% if the used calibration method is DisplayUndistortionBVL, otherwise the
% resolution parameters are ignored by the other calibration methods.
%
% Higher numbers for mesh resolution == finer undistortion but longer draw
% time. 'exampleImage' must be the handle to a texture or offscreen window
% that has the same size, color depth and format as the input images you're
% gonna use later on, otherwise weird things will happen.
AddImageUndistortionToGLOperator(gloperator, exampleImage, calibfilename, 0, 73, 73);

% Draw original image into exampleImage, scale it up to offscreen window size:
Screen('DrawTexture', exampleImage, mytex, [], woffrect);

% Draw some centered text for illustration...
Screen('TextSize', exampleImage, 64);
DrawFormattedText(exampleImage, 'Hello World', 'center', 'center', [0 255 0]);

% Ok, exampleImage contains the "distorted" oversized image we want to
% undistort and scale by application of our gloperator. Apply it,
% undistortedImage will contain the new undistorted image:
undistortedImage = Screen('TransformTexture', exampleImage, gloperator, [], undistortedImage);

% Draw undistorted image to onscreen window:
Screen('DrawTexture', w, undistortedImage);

% Show it:
Screen('Flip', w);

% Wait for keypress:
KbStrokeWait;

% Close all windows and ressources:
Screen('CloseAll');

return;