[M,N] = size(FileName);
FileName = FileName(1,1:N-4);
%         data=double(ImageData);
data=ImageData;

% subplot(2,1,1);
% imagesc(data);
% colorbar;
% title(FileName);
% %colormap('gray');
% axis equal
% 
% %sets up axis to display at 1mm grid spacing
% set(gca,'XTickMode','manual')
% set(gca,'YTickMode','manual')
% set(gca,'XTick',80:560:length(data))  %164px =1 mm in poking eyeball nikon(maybe)
% set(gca,'YTick',100:280:length(data))   %110px =1 mm in beach ball olympus(maybe)
% set(gca,'GridLineStyle','-')
% grid on
% 
% 
% data2=ImageData(661:941,621:1180);  %zoomed in subplot of ~2mmx2mm
% subplot(2,1,2);
% imagesc(data2);
% colorbar;
% colormap('gray');
% axis equal
% 
% set(gca,'XTickMode','manual')
% set(gca,'YTickMode','manual')
% set(gca,'XTick',1:56:length(data))  %based on sieved grain sizes,
% set(gca,'YTick',1:56:length(data))   %75px ~=1 mm in beach ball olympus
% %       set(gca,'GridLineStyle','-')
% %       grid on
% pause(0.2)
%         FileName  % Write image name in command window.
if run_type == 0;
    AutoCorrPixStep; % Calculate mean grain size.3
elseif run_type == 1;
%     AutoCorrS;
    AutoCorrS_Vert;
else
    break
    return
end;
