How to compare histogram with threshold?

3 views (last 30 days)
pritesh patel
pritesh patel on 4 Mar 2015
Answered: intissar khalifa on 28 Jan 2018
Hello, I am new to MATLAB. In my project for key-frame extraction from videos, first I am computing Histogram of consecutive frames. I also compute threshold as threshold=std+mean*4; Now, I have to check whether HistDiff(k)>threshold. But my question is HistDiff(k) is histogram difference i.e. 1D array and threshold is single numeric value. So, How to do it.( I attached a file, if required) I am stuck in this. Please help.

Answers (2)

Image Analyst
Image Analyst on 4 Mar 2015
Edited: Image Analyst on 4 Mar 2015
Try looking at the average difference over all bins
if mean(HistDiff) > threshold
% It's a key frame
else
% It's not a key frame
end
By the way, don't you want
threshold = stdDev*4;
instead of
threshold=std+mean*4
The mean * 4 will get clipped to 255 most likely so you'll never exceed it. Also, be sure not to use mean or std as variable names since they're built-in functions. And you don't want to add the mean because the difference has the mean already subtracted out.
  2 Comments
pritesh patel
pritesh patel on 4 Mar 2015
Ok, but if I have HistDiff(k) is an array and mean too or otherwise. So , how to compare them.
if threshold=mean;
% then how to compute
HistDiff(k)>mean;
end
I am getting problem in this stage:
HistDiff(k)>threshold; %if threshold=mean
Image Analyst
Image Analyst on 4 Mar 2015
I told you exactly how. Why didn't you use my code and instead changed it to something that doesn't work? There are numerous problems with your code like bad syntax, comparing floating point numbers for equality, bad indenting, etc. What is HistDiff exactly? Is it an array that is the histogram of the current image minus the histogram of the last key frame? Or is it the mean difference over all gray level bins and k is the frame number?

Sign in to comment.


intissar khalifa
intissar khalifa on 28 Jan 2018
i have some videos from job iterview and i like to get for each video the key frames for feature extraction can you help me please

Community Treasure Hunt

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

Start Hunting!