

fold = 1.1; 
imName = 'tb.jpg'; % a testing image
im = imread(imName);
if size(im,3) == 3
    im = rgb2gray(im); % transform image from color to gray
end
J{1} = double(imresize(im, fold, 'nearest')); 
towrite = J{1}; 
outepsgif(towrite, 'ex7_original'); 
[sx1 sy1] = size(J{1}); 
Sx1 = zeros(1, 1)+sx1; Sy1 = zeros(1, 1)+sy1; 

disp(['computing S1 maps']);
tic
S1map = applyfilterfftsame(J, allfilter);  % filter training images
Ctransform(1, norient, S1map, Sx1, Sy1, Upperbound);
disp(['S1 maps take: ' num2str(toc) ' seconds']);
figure; 
for (o = 1:norient)
    subplot(5, 5, o); imshow(-S1map{1, o}, []); 
end

disp(['computing M1 maps']);
tic
sub1 = 1; Lrange1 = 6; 
M1map = initialmax(J, allfilter);  % to be changed to local maximum
CMax1(1, norient, S1map, M1map, h, Lrange1, Orange, sub1, Sx1, Sy1);
disp(['M1 maps take: ' num2str(toc) ' seconds']);
figure; 
for (o = 1:norient)
    subplot(5, 5, o); imshow(-M1map{1, o}, []); 
end


