Histogram Difference error Code, HLP pls

5 ビュー (過去 30 日間)
Dracfov
Dracfov 2019 年 2 月 9 日
コメント済み: Dracfov 2019 年 2 月 10 日
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

回答 (1 件)

Image Analyst
Image Analyst 2019 年 2 月 9 日
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 件のコメント
Image Analyst
Image Analyst 2019 年 2 月 9 日
Make it easy for us to help you.
Attach 'Avirio.mp4' with the paper clip icon. Zip it if you have to.
Dracfov
Dracfov 2019 年 2 月 10 日
Good morning dear friend, thank you for giving me the help, here I attached the video and the document.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by