Merge branch 'feature-OctaveRGB' into develop

This commit is contained in:
Loic Delattre 2023-02-06 15:37:41 +01:00
commit 1dd5c73423
5 changed files with 104 additions and 2 deletions

27
RGB_traces.m Normal file
View File

@ -0,0 +1,27 @@
%%%%%%%%%%%%%%%%%%%%%
% function RGB_avg = RGB_traces (input1)
% ex. RGB_avgs = 2DRotationMatrix('frame0.jpg')
%
% Task: Extracting the average RGB values of a frame
%
% Inputs:
% - input1: frame adress on pc
%
% Output:
% -RGB_avg: a 1x3 matrix with the RGB average values, format -> [R, G, B]
%
% author: Loic Delattre (loic.delattre@ecam.fr)
% date: 06/02/2023
%%%%%%%%%%%%%%%%%%%%%
function RGB_avg = RGB_traces (image)
I = imread (image);
RGB_avg = [];
i = 3;
j = 1;
while i >= 1
RGB_avg(j) = matrix_avg (I(:,:,i));
j = j + 1;
i = i - 1;
endwhile
endfunction

36
frames_RGBs.m Normal file
View File

@ -0,0 +1,36 @@
%%%%%%%%%%%%%%%%%%%%%
% function RGB_avg = RGB_traces (input1)
% ex. RGB_avgs = 2DRotationMatrix('frame0.jpg')
%
% Task: Extracting the average RGB values of a frame
%
% Inputs:
% - input1: frame adress on pc
%
% Output:
% -RGB_avg: a 1x3 matrix with the RGB average values, format -> [R, G, B]
%
% author: Loic Delattre (loic.delattre@ecam.fr)
% date: 06/02/2023
%%%%%%%%%%%%%%%%%%%%%
function RGB_data = frames_RBGs ()
%frames_num = 918;
j = 0;
RGB_data = [0, 0, 0];
while j <= 10000
try
image = strcat('frames/frame', int2str(j), '.jpg');
j = j + 1;
i = 3;
while i >= 1
RGB_data(i, j) = RGB_traces (image)(i);
i = i - 1;
endwhile
catch
disp('scanned all frames')
j = 10001
end_try_catch
endwhile
endfunction

View File

@ -64,5 +64,5 @@ def get_frames(vid):
cap.release()
cv2.destroyAllWindows()
return
get_frames(video)
return i
print('number of frames extracted ' + get_frames(video))

22
matrix_avg.m Normal file
View File

@ -0,0 +1,22 @@
%%%%%%%%%%%%%%%%%%%%%
% function RGB_avg = RGB_traces (input1)
% ex. RGB_avgs = 2DRotationMatrix('frame0.jpg')
%
% Task: Extracting the average RGB values of a frame
%
% Inputs:
% - input1: frame adress on pc
%
% Output:
% -RGB_avg: a 1x3 matrix with the RGB average values
%
% author: Loic Delattre (loic.delattre@ecam.fr)
% date: 06/02/2023
%%%%%%%%%%%%%%%%%%%%%
function Mavg = matrix_avg (M)
col = size(M,2);
row = size(M,1);
num_items = col*row;
Mavg = sum(sum(M))/num_items;
endfunction

17
test_file.m Normal file
View File

@ -0,0 +1,17 @@
clear all
close all
clc
threshold = 1e-6;
RGB_data = frames_RGBs ();
%TEST 1
%Average of all the items inside of a matrix
A = [1, 2; 3, 4];
avg = 2.5;
if matrix_avg (A) - avg < threshold
disp('Test 1 passed gg')
else
disp('Test 1 failed, f')
endif