ROI analysis
This commit is contained in:
parent
6a50638753
commit
65f25bb19d
|
|
@ -11,12 +11,11 @@
|
||||||
% 06/04/2021
|
% 06/04/2021
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
function [frame] = picToROI(imgWidth,imgHeight,nbIm,d)
|
function [gROI] = picToROI(imgWidth,imgHeight,nbIm,d)
|
||||||
|
display("piToRoi Start")
|
||||||
files = dir('*.jpg');
|
files = dir('*.jpg');
|
||||||
ROI = zeros (3*d/2,3*d+1,nbIm,3);
|
ROI = zeros (3*d/2,3*d+1,nbIm,3);
|
||||||
display("ok1");
|
|
||||||
for n=1:1:nbIm
|
for n=1:1:nbIm
|
||||||
display("ok2");
|
|
||||||
files(n).name
|
files(n).name
|
||||||
frame = imread (files(n).name);
|
frame = imread (files(n).name);
|
||||||
|
|
||||||
|
|
@ -24,12 +23,12 @@ function [frame] = picToROI(imgWidth,imgHeight,nbIm,d)
|
||||||
for i=1:1:3*d/2 %imgHeight*0.5-d*5/2:1:3*d/2
|
for i=1:1:3*d/2 %imgHeight*0.5-d*5/2:1:3*d/2
|
||||||
for j=1:1:3*d %imgWidth*0.5-3*d/2:1:3*d
|
for j=1:1:3*d %imgWidth*0.5-3*d/2:1:3*d
|
||||||
|
|
||||||
ROI(i,j,n,1) = Image(i+imgHeight*0.5-d*5/2,j+imgWidth*0.5-3*d/2,1);
|
rROI(i,j,n) = Image(i+imgHeight*0.5-d*5/2,j+imgWidth*0.5-3*d/2,1)*255;
|
||||||
ROI(i,j,n,2) = Image(i+imgHeight*0.5-d*5/2,j+imgWidth*0.5-3*d/2,1);
|
gROI(i,j,n) = Image(i+imgHeight*0.5-d*5/2,j+imgWidth*0.5-3*d/2,2)*255;
|
||||||
ROI(i,j,n,3) = Image(i+imgHeight*0.5-d*5/2,j+imgWidth*0.5-3*d/2,1);
|
bROI(i,j,n) = Image(i+imgHeight*0.5-d*5/2,j+imgWidth*0.5-3*d/2,3)*255;
|
||||||
|
|
||||||
endfor
|
endfor
|
||||||
endfor
|
endfor
|
||||||
endfor
|
endfor
|
||||||
|
display("piToRoi End")
|
||||||
endfunction
|
endfunction
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
%function []= plotAverage(ROI,nbIm, fps)
|
||||||
|
%
|
||||||
|
% Task: plotting the average color of the ROI over time
|
||||||
|
%
|
||||||
|
% Inputs:
|
||||||
|
% - ROI: 3D matrix, Region of interest, made out of 'nbIm' different images
|
||||||
|
% - nbIm: integer, number of images stored from the video
|
||||||
|
% - fps: frames per seconds of the video
|
||||||
|
%
|
||||||
|
% Outputs:
|
||||||
|
% - plot of the average color of the ROI as a function of time
|
||||||
|
%
|
||||||
|
% Antoine Rodary - Julian Leclerc - Gwenn Durpoix-Espinasson - Luc Pichot
|
||||||
|
% 06/04/2021
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
|
|
||||||
|
function [averageArray]= plotAverage(ROI,nbIm, fps)
|
||||||
|
display("PlotAv Start")
|
||||||
|
% passing through each image of the video
|
||||||
|
averageArray = zeros(1,nbIm);
|
||||||
|
[n,m,Nimg]=size(ROI);
|
||||||
|
for k = 1:nbIm
|
||||||
|
% calculating the average value of the ROI
|
||||||
|
sum = 0;
|
||||||
|
for i = 1:n
|
||||||
|
for j = 1:m
|
||||||
|
sum = sum + ROI(i,j,k);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
average = sum/(i*j);
|
||||||
|
%storing
|
||||||
|
averageArray(k)= average;
|
||||||
|
end
|
||||||
|
xAxis = [0:(1/fps):(nbIm/fps)-(1/fps)];
|
||||||
|
figure(1);
|
||||||
|
plot(xAxis, averageArray);
|
||||||
|
title('Average color of the ROI over time')
|
||||||
|
xlabel('t (s)')
|
||||||
|
ylabel('Average color of the ROI')
|
||||||
|
display("PlotAv End")
|
||||||
|
endfunction
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
%function []= plotFFT(averageArray, nbIm, fps)
|
||||||
|
%
|
||||||
|
% Task: plotting the fast fourier transform of the average color of the ROI
|
||||||
|
%
|
||||||
|
% Inputs:
|
||||||
|
% - averageArray : function of the average color of the ROI over time
|
||||||
|
% - nbIm : integer, number of images stored from the video
|
||||||
|
% - fps : frames per seconds of the video
|
||||||
|
%
|
||||||
|
% Outputs:
|
||||||
|
% - plot of the fast fourier transform of the average color of the ROI
|
||||||
|
%
|
||||||
|
% Antoine Rodary - Julian Leclerc - Gwenn Durpoix-Espinasson - Luc Pichot
|
||||||
|
% 06/04/2021
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
|
function []= plotFFT(averageArray, nbIm,fps)
|
||||||
|
|
||||||
|
display("Plot FFT Start")
|
||||||
|
Fs = fps; % Sampling frequency
|
||||||
|
T = 1/Fs; % Sampling period
|
||||||
|
L = nbIm; % Length of signal
|
||||||
|
t = (0:L-1)*T; % Time vector
|
||||||
|
Y = fft(averageArray);
|
||||||
|
|
||||||
|
P2 = abs(Y/L);
|
||||||
|
P1 = P2(1:L/2+1);
|
||||||
|
P1(2:end-1) = 2*P1(2:end-1);
|
||||||
|
f = Fs*(0:(L/2))/L;
|
||||||
|
figure(2);
|
||||||
|
plot(f,P1)
|
||||||
|
title('Fast Fourier Transform of the signal of the average color of the ROI')
|
||||||
|
xlabel('f (Hz)')
|
||||||
|
ylabel('|P1(f)|')
|
||||||
|
display("Plot FFT End")
|
||||||
|
hold on;
|
||||||
|
endfunction
|
||||||
|
|
@ -1 +1,10 @@
|
||||||
M = picToROI(750,480,5,26);
|
fps = 30;
|
||||||
|
nbIm = 300;
|
||||||
|
|
||||||
|
%rROI = picToROI(750,480,nbIm,26,1);
|
||||||
|
gROI = picToROI(750,480,nbIm,26,1);
|
||||||
|
%bROI = picToROI(750,480,nbIm,26,1);
|
||||||
|
|
||||||
|
hold
|
||||||
|
averageArray = plotAverage(gROI,nbIm, fps);
|
||||||
|
plotFFT(averageArray, nbIm,fps);
|
||||||
Loading…
Reference in New Issue