% % nimOut = Edge_contrast_circle_animation( flRadius, imDim, flAngle, flPhaseStart, 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. Edge speed % is flPxShiftMax*nFrameRate/24(see hardcoded nFrameRate). % flDuration - Approximate duration of one cycle of the animation, % in pixels/second. This will be rounded to the nearest % increment of the frame duration (see hardcoded nFrameRate). % % 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: % % nimOut - Grayscale [ imDim x imDim ] 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 nimOut = Edge_contrast_circle_animation( flRadius, imDim, nAngle, nPhaseStart, flPxShiftMax, flDuration ) flAngle = nAngle*pi/180; flPhaseStart = nPhaseStart*pi/180; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % hardcoded parameters strFilestem = [ 'Circle-' num2str(flRadius) '_' num2str(imDim) '_' num2str(nAngle) '_' num2str(nPhaseStart) '_' num2str(flPxShiftMax) '_' num2str(flDuration) ]; strFileFormat = '.png'; nOverSample = 5; nFrameRate = 24; bShowResult = 0; % [0,1] bWriteEachFrame = 0; % [0,1] bWriteSpaceVolume = 0; % [0,1] % hardcoded parameters %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% flShiftMax = 24*flPxShiftMax/nFrameRate; % maximum shift, in pixels % nFramesPerCycle = (flDuration*nFrameRate) % nDegreesPerFrame = 360(degrees/cycle)/nFramesPerCycle nDegreesPerFrame = round( 360/(flDuration*nFrameRate) ); nDegreesPhaseStart = flPhaseStart*180/pi; i = 0; for ndegPhase = nDegreesPhaseStart : nDegreesPerFrame : 360 + nDegreesPhaseStart - nDegreesPerFrame i = i + 1; nimOut(:,:,i) = Edge_contrast_circle( flRadius, imDim, flAngle, ndegPhase, flShiftMax ); if bWriteEachFrame imwrite( nimOut(:,:,1), [ strFilestem '_' num2str(ndegPhase) strFileFormat ] ); end end nimOut = permute( nimOut, [ 1 3 2 ] ); if bWriteSpaceVolume write_Space_volume( nimOut, [ strFilestem ] ); end if bShowResult imshow( nimOut(:,:,1) ) end