% % nvolOut = ECC_animation_2x2( flRadius, imDim, flPxShiftMax, flDuration ) % ------------------------------------------------------------------------- % % Creates a set of circle with center-surround frames of a movie for % a "directional edge contrast motion" illusion. % % USAGE: nimOut = Edge_contrast_circle_animation( 25, 100, 45, 90, 36, 1.0 ); % % INPUT: % % flRadius - Circle radius, in pixels. % imDim - One dimension of the resulting square image, in % pixels, unless this dimension will clip the circle image. % nAngle - Direction of apparent motion, in degrees. % nPhaseStart - First frame phase, in degrees. % flPxShiftMax - Proportional to maximum edge shift. Also set appropriate % animation frame rate (see hardcoded nFrameRate). % flDuration - Duration of one cycle of the animation, in pixels/second. % (For flSpeedPxpS = 24 and the hardcoded nFrameRate = 24, % the valid values include [ 1/12, 1/8, 1/6, 1/4, 1/3, 1/2, 15/24, 1, 3/2, 5/3, 15/8, 5/2, 15/4, 5 ] % constrained by the condition: 360/(flDuration*nFrameRate)is integral. % % HARDCODED (immediately below function declaration): % % strFilestem - File stem naming of output file. % strFileFmt - File extension that specifies the image format, % e.g.'.png', '.tif', '.jpg', etc. % nOverSample - [1, 16] Flat aperture oversampling rate. % nFrameRate - Expected animation frame rate. % % bShowResult - [0, 1] Display final image (only last frame). % bWriteResult - [0, 1] Write image to file. % % RETURN VALUES: % % nvolOut - Grayscale [ imDim x imDim x #frames ] image array of 8-bit integers % (uint8). % % OUTPUT: % % If bWriteResult == 1, writes grayscale image to current directory. % % FUNCTION CALLS and DEPENDENCIES: % % Edge_contrast_circle.m % write_Space_volume.m % % % Mark Dow, May 5, 2008 % Mark Dow, modified May 6, 2008 (added phase and maximum shift) % % % TERMS FOR USE: There are no restrictions on the use of this code, % auxilliary code and other required resources. Claiming % to be the originator, explicitly or implicitly, is bad % karma. A link (if appropriate), a note to dow[at]uoregon.edu, % and credit are appreciated but not required. % function nvolOut = ECC_animation_2x2( flRadius, imDim, flPxShiftMax, flDuration ) % flAngle = nAngle*pi/180; % flPhaseStart = nPhaseStart*pi/180; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % hardcoded parameters %strStem = 'Circles-2x2'; strStem = 'test'; %dir = [ 45 135 225 315 ]; % radial opposite %strStem = 'RO1'; % dir = [ 45 315 225 135 ]; % radial in % strStem = 'RO2'; dir = [ 135 45 315 225 ]; % CCW strStem = [ strStem '-CW' ]; % dir = [ 315 225 135 45 ]; % CCW % strStem = [ strStem '-CCW' ]; % phase = [ 0 180 0 180 ]; % alternating phase % strStem = [ strStem '-PA' ]; phase = [ 0 0 0 0 ]; % no phase difference strStem = [ strStem '-P0' ]; % phase = [ 30 30 30 30 ]; % no phase difference % strStem = [ strStem '-P30' ]; % phase = [ 45 45 45 45 ]; % no phase difference % strStem = [ strStem '-P45' ]; % phase = [ 90 90 90 90 ]; % no phase difference % strStem = [ strStem '-P90' ]; % phase = [ 270 180 90 0 ]; % cyclic CCW % strStem = [ strStem '-PCCW' ]; % phase = [ 0 90 180 270 ]; % cyclic CW % strStem = [ strStem '-PCW' ]; strStem = [ strStem '-gray' ]; strFilestem = [ strStem '-' num2str(flRadius) '_' num2str(imDim) '_' num2str(flPxShiftMax) '_' num2str(flDuration) ] nOverSample = 5; nFrameRate = 24; % hardcoded parameters %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% nvolOut( 1:2*imDim, flDuration*24, 1:2*imDim ) = 127; %flPxShiftMax*flDuration nimQquad = Edge_contrast_circle_animation( flRadius, imDim, dir(1), phase(1), flPxShiftMax, flDuration ); % size(nimQquad) % size(nvolOut) szQquad = size( nimQquad ); number_of_frames = szQquad(2) % To Do: Warn when the sub-image must be clipped. % szQquad(1)/2 - imDim/2 + 1 % szQquad(1)/2 - imDim/2 + imDim % szQquad(3)/2 - imDim/2 + 1 % szQquad(3)/2 - imDim/2 + imDim nvolOut( 1:imDim, :, 1:imDim ) = nimQquad( szQquad(1)/2 - imDim/2 + 1 : szQquad(1)/2 - imDim/2 + imDim, :, szQquad(3)/2 - imDim/2 + 1 : szQquad(3)/2 - imDim/2 + imDim ); nimQquad = Edge_contrast_circle_animation( flRadius, imDim, dir(2), phase(2), flPxShiftMax, flDuration ); nvolOut( imDim + 1:2*imDim, :, 1:imDim ) = nimQquad( szQquad(1)/2 - imDim/2 + 1 : szQquad(1)/2 - imDim/2 + imDim, :, szQquad(3)/2 - imDim/2 + 1 : szQquad(3)/2 - imDim/2 + imDim ); nimQquad = Edge_contrast_circle_animation( flRadius, imDim, dir(3), phase(3), flPxShiftMax, flDuration ); nvolOut( imDim + 1:2*imDim, :, imDim + 1:2*imDim ) = nimQquad( szQquad(1)/2 - imDim/2 + 1 : szQquad(1)/2 - imDim/2 + imDim, :, szQquad(3)/2 - imDim/2 + 1 : szQquad(3)/2 - imDim/2 + imDim ); nimQquad = Edge_contrast_circle_animation( flRadius, imDim, dir(4), phase(4), flPxShiftMax, flDuration ); nvolOut( 1:imDim, :, imDim + 1:2*imDim ) = nimQquad( szQquad(1)/2 - imDim/2 + 1 : szQquad(1)/2 - imDim/2 + imDim, :, szQquad(3)/2 - imDim/2 + 1 : szQquad(3)/2 - imDim/2 + imDim ); write_Space_volume( nvolOut, [ strFilestem ] );