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


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

% y-coordinate defining the vertical center of the ROI
y_center_line = 360;



% XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
%
%                             DO NOT MODIFY THE SCRIPT BEYOND THIS POINT
%
% XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
lw = 2;

% camera parameters
PixNrx      =       1280;
PixNry      =       720;

% select a channel 
Red_1 = I_1(:,:,1);
Green_1 = I_1(:,:,2);
Blue_1 = I_1(:,:,3);
% format conversion
Red_1 = double(Red_1);
Green_1 = double(Green_1);
Blue_1 = double(Blue_1);
% select a line of interest ROI (1 x 1600), here center line on position 600
CenterLine_Red = Red_1(y_center_line,:);
CenterLine_Green = Green_1(y_center_line,:);
CenterLine_Blue = Blue_1(y_center_line,:);


imagesc(I_1)

%plot a single line
figure('color','w','Position', [98.6000 586.6000 1.8464e+03 380])

subplot(1,4,1)
hold on
imagesc(I_1)
plot([0 PixNrx],[1 1]*y_center_line,'-r','linewidth',lw)
xlabel('Position x (pixel)')
ylabel('Position y (pixel)')
axis square
axis tight


subplot(1,4,2)
plot(CenterLine_Red,'LineWidth',lw)
title("Red channel")
xlabel('Position x (pixel)')
ylabel('Signal (counts)')
ylim([0 255])
xlim([1 PixNrx])
axis square

subplot(1,4,3)
plot(CenterLine_Green,'LineWidth',lw)
title("Green channel")
xlabel('Position x (pixel)')
ylabel('Signal (counts)')
ylim([0 255])
xlim([1 PixNrx])
axis square

subplot(1,4,4)
plot(CenterLine_Blue,'LineWidth',lw)
title("Blue channel")
xlabel('Position x (pixel)')
ylabel('Signal (counts)')
ylim([0 255])
xlim([1 PixNrx])
axis square