Histogram Difference error Code, HLP pls
5 ビュー (過去 30 日間)
古いコメントを表示
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.

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.

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
0 件のコメント
回答 (1 件)
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
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.
参考
カテゴリ
Help Center および File Exchange で Data Distribution Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!