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.

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
回答(1 个)
Image Analyst
2019-2-9
0 个投票
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 个评论
Dracfov
2019-2-9
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
2019-2-10
类别
在 帮助中心 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!