function Histgram(file_in)
% Display and Save Histgram of 2D Image
% Input Image as file_in

% file_in = 'test_c.jpg';

% Spatial Domain
% file_in = 'INT_a=0.960.png';
% file_in = 'INT_a=1.000.png';
% file_in = 'INT_a=1.040.png';
% file_in = 'F_Kiya_INT_a=0.960.png';
% file_in = 'F_Kiya_INT_a=1.000.png';
% file_in = 'F_Kiya_INT_a=1.040.png';

% Fourier Domain
% file_in = 'FSP_001.png';
% file_in = 'FSP_005.png';
% file_in = 'FSP_009.png';
% file_in = 'F_Kiya_FSP_001.png';
% file_in = 'F_Kiya_FSP_005.png';
% file_in = 'F_Kiya_FSP_009.png';


Img = double(imread(file_in));
ImgG = uint8(0.299*Img(:,:,1)+0.587*Img(:,:,2)+0.114*Img(:,:,3));
% ImgG = uint8(rgb2gray(Img));

[xsize ysize] = size(ImgG);
hg = zeros(256,1);

%
for i=1:xsize
    for j=1:ysize
        hg(ImgG(i,j)+1) = hg(ImgG(i,j)+1) + 1;
    end
end
%

%{
figure(1);
imagesc(Img);
%}

%{
figure(2);
subplot(1,2,1), imagesc(ImgG);
% I = imread(file_in); subplot(1,2,1), imagesc(I);
subplot(1,2,2), bar(hg);
colormap(gray);
%}

file_name = sprintf('Histgram_%s',file_in);
f = figure(2);
bar(hg);
colormap(gray);
saveas(f,file_name,'png');

end

