Histogram Difference error Code, HLP pls

Hi all.
I hope that before proceeding to the reading of my doubt, everyone is well.
Dear colleagues, I am trying to calculate the Histogram difference using the equation of this article.
Sin título.jpg
Where,
n is the total number frames.
h1 is the current frame.h2 is the next frame
***********************************************
This is the code that I am using.
Video_Input = 'Avirio.mp4'; %Video Name
Video_Obj = VideoReader(Video_Input); %Using Command (Videoreader) for reading video
%Extracting frames
Total_Frame_Video_Obj= Video_Obj.NumberOfFrames; % Calculating number of frames
for i=1:Total_Frame_Video_Obj-1
C_Frame=read( Video_Obj,i); % "Select the Current Frame"
if(i~=Total_Frame_Video_Obj)
N_Frame=read( Video_Obj,i+1); % "Select the Next Frame"
%To calculate histogram difference between two frames
HD=Histogram_difference(C_Frame,N_Frame,Total_Frame_Video_Obj);
FrametoFrameDiff(i)=HD;
end
end
function [ res ] = Histogram_difference( C_Frame,N_Frame,Total_Frames)
Hist_CF=imhist(C_Frame); %histogram of data
Hist_NF=imhist(N_Frame);
%difference=imabsdiff(Hist_CF,Hist_NF);
difference=(1/Total_Frames^2)*(256*(((Hist_CF-Hist_NF).^2)/max(Hist_CF,Hist_NF)));
res=sum(difference);
end
if I use the equation before mentioned the following error is generated.
Sin título1.jpg
but if I use Matlab own equation "imabsdiff", the code works perfectly.
Please could someone help me and rectify what is my mistake.
Thanks and everyone have an excellent weekend

Réponses (1)

Image Analyst
Image Analyst le 9 Fév 2019

0 votes

HD is not a scalar, which it needs to be in order to be the i'th element of FrameToFrameDiff. HD is a vector with more than one element.

3 commentaires

Dracfov
Dracfov le 9 Fév 2019
Thank you dear friend, but I still have my doubts, how to implement, could you show me an example.
Image Analyst
Image Analyst le 9 Fév 2019
Make it easy for us to help you.
Attach 'Avirio.mp4' with the paper clip icon. Zip it if you have to.
Dracfov
Dracfov le 10 Fév 2019
Good morning dear friend, thank you for giving me the help, here I attached the video and the document.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Data Distribution Plots dans Centre d'aide et File Exchange

Tags

Question posée :

le 9 Fév 2019

Commenté :

le 10 Fév 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by