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 CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by