% Program Name: EXMPL_01.M % Author: W.J. Dallas. Date: 10 Feb 95. % Last modified: ----- % Based on: ----- % This program generates a uniformly filled matrix, performs the % checkerboard-equivalent quadrant shift, does a fast Fourier transform, % takes the absolute value of the results, scales the results to the range % 0 to 63 and displays those results as an image. Notice the semicolon at % the end of each line. The semicolons are very important. They suppress % writing all matrix values to the screen. Should you omit a semicolon, % you may get a very large number of characters written to the screen. % Should this happen, you can interrupt the operation by hitting % on the keyboard. %---- BEGIN BLOCK---- FIGURE INITIALIZATION % % This figure initialization comes from the file PROTOTYP.M, it allows you % to choose the figure size. The choice is in terms of a screen size, % for the Op_Sci Micro-computer Lab, the maximum screen size is % 1024x768. The program automatically positions two figure windows at the % bottom of the screen. % Select the screen size. choice = menu('Screen Size','640x480','800x600','1024x768','1280x1024'); screen_res = choice; % Position parameters [x_first y _first x_width y_width] % x is measured from the left of the screen with a minimum of 4. % y is measured from the bottom of the screen with a minimum of 4. % Set the sizes and position the figures. if screen_res == 1 % 640x480 figure_1 = [4 4 312 312]; figure_2 = [323 4 312 312]; elseif screen_res == 2 % 800x600 figure_1 = [4 4 393 393]; figure_2 = [404 4 393 393]; elseif screen_res == 3 % 1024x768 figure_1 = [4 4 504 504]; figure_2 = [515 4 504 504]; elseif screen_res == 4 % 1280x1024 figure_1 = [4 4 632 632]; figure_2 = [643 4 632 632]; else text_buffer = ' Illegal Screen-Size Choice -- EXITING'; disp(text_buffer); return; end % Open the first figure window, position and clear it. handle_1 = figure(1); set(handle_1,'position',figure_1); clf; clc; home; % Open the second figure window, position and clear it. handle_2 = figure(2); set(handle_2,'position',figure_2); clf; clc; home; % Load and set the colormaps for both figures. load graymap; figure(1); colormap(map); figure(2); colormap(map); % %---- END BLOCK ---- %---- BEGIN BLOCK---- FILL THE OBJECT % object=ones(32,32); % %---- END BLOCK ---- %---- BEGIN BLOCK---- QUADRANT SHIFT % u=fftshift2(object); % %---- END BLOCK ---- %---- BEGIN BLOCK---- FFT % u=fft2(u); % %---- END BLOCK ---- %---- BEGIN BLOCK---- QUADRANT SHIFT % u=fftshift2(u); % %---- END BLOCK ---- %---- BEGIN BLOCK---- ABSOLUTE VALUE^2 % u=(abs(u)).^2; % %---- END BLOCK ---- %---- BEGIN BLOCK---- NORMALIZE % object=63*object/(max(max(object))); u=63*u/(max(max(u))); % %---- END BLOCK ---- %---- BEGIN BLOCK---- DISPLAY % figure(1); image(object); text_buffer=' OBJECT'; title(text_buffer); figure(2); image(u); text_buffer='DFT--Press to Finish'; title(text_buffer); pause; % %---- END BLOCK ---- %---- BEGIN BLOCK---- CLEAN UP AND EXIT. % clear; close(1); close(2); % %---- END BLOCK ---- % %!!!!!!!!!!!!!!!! END OF M-FILE