function nma_EECS_203A_HW4_prob_a

M=480;  % rows
N=640;  % columns
fileName='triangle.raw';
%img=imread(imageFileName,'ras');

 
fid=fopen(fileName,'r');
f=fread(fid,[N,M],'uint8');
fclose(fid);

f=f';

figure;
imagesc(f,[0 255]);
colormap gray;
colorbar;
title(sprintf('Original raster file %s',fileName));

figure;

F = fft2(f,M,N);
F = fftshift(F); % Center FFT
F = abs(F);  % Takes the magnitude of F
F = round(F);

c=22;
imagesc(c*log(1+F),[0 255]); colormap gray; 
title(sprintf('|F| for triangle. Scaled with c log(1+F), c=%d',c));
xlabel('v'); ylabel('u');

figure;
mesh(1:N,1:M,.6*log(1+F)); colormap jet;
xlabel('v'); ylabel('u');
title(sprintf('3D view of |F| for triangle. Scaled with c log(1+F), c=%d',c));


figure;
c=1;
for (i=1:25)
     subplot(5,5,c);
     imagesc(i*log(1+F),[0 255]); colormap gray; title(sprintf('c=%d',c));
     c=c+1;
end
