close all; clc
%% =====================================================================================================
% Parameters to be modified

% Read an image
Im = imread('picture 1.jpg');

% Define the y-coordinate of a line of interest (LOI) where the mean RGB
% value is computed
line_y = 360;

% Show LOI (1 = show LOI, 0 = hide LOI)
show_LOI = 1;




% XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
%
%                             DO NOT MODIFY THE SCRIPT BEYOND THIS POINT
%
% XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX



%% =====================================================================================================
% Process data

% parameters camera
PixNrx          =       1280;
PixNry          =       720;

% convert to B&W - makes a mean of three intensity values for blue, green
% and red
I = mean(Im(line_y,:,:),3);

%% =====================================================================================================
% Plot data

figure('Color','w','Position', [250 250 1051 425])

% visiualize the image 
subplot(1,2,1)
imagesc(Im) 
hold on
if show_LOI
    plot([1 PixNrx],[line_y line_y],'r','LineWidth',2)
end
colormap gray
title('Image')
xlabel('Position x (pixel)')
ylabel('Position y (pixel)')
 
% plot a single line
subplot(1,2,2)
plot(I,'k','LineWidth',2)
xlabel('Position x (pixel)')
ylabel('Signal (counts)')
title(['Mean RGB signal at y = ' num2str(line_y)])
xlim([1 PixNrx])
ylim([0 255])
 

