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

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

% Define a region of interest (ROI) over which the mean and std values will be evaluated.
% x-coordinates of the ROI
x_start = 470;
x_end   = 535;
% y-coordinates of the ROI
y_start = 275;
y_end   = 375;




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



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

% camera parameters
PixNrx      =       1280;
PixNry      =       720;

% convert to B&W
I = mean(Im,3);

% select ROI
I_ROI = I(y_start:y_end,x_start:x_end);

% compute mean and std values over ROI
MEAN_ROI = mean(mean(I_ROI))
STD_ROI  = mean(std(I_ROI))

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

figure('color','w')

% display the image
hold on
imagesc(flipud(Im))
rectangle('position',[x_start y_start x_end-x_start y_end-y_start],'edgecolor','r','linewidth',2)
axis tight
xlabel('Position x (pixel)')
ylabel('Position y (pixel)')
title('Image with highlighted region of interest')


