Faster histogram then histcounts

Does anyone know faster method, which create histogram data then histcounts? Function must include cases when some values are outside edges and when bins are empty.

Answers (1)

Image Analyst
Image Analyst on 23 Jan 2016
How many data points do you need, and how are you going to use the histogram counts? If you have lots of data (tens of millions of points) and just need to do something like figure out a threshold or skewness or something, then you could most likely get the same result by analyzing just a subsample of your data, like the first tenth of it or some fraction. Would that work for you?

6 Comments

Unfortunately, that wouldn't work for me, because I use hiscount in a loop for small amount of data. The function doesn't take very long but I must repeat it many times.
If it's a small amount of data, just try taking the histogram yourself manually with a for loop. Also, define "many" - is that 10 million times, or a billion times, or more?
I tried to do it with loops but it was much slower. I do it probably 1000 times but it is part of video analision and I do it 1000 times on each frame. I wanted to do it in real-time so it shoud take less than 0.03s. I gues I will have to give up real-time.
Why do you need to do it 1000 times on each frame? The histogram won't change on one specific frame.
You still haven't said why my subsampling idea won't work. I think it should.
The idea is to crop fragment of the frame, count histogram, compare it with model and move to next section. After I analize whole frame I find maximum similarity with model and mark corresponding place as searched object. Subsampling woudn't work because I crop small fragment of frame which doesn't have so many pixels and I'm afraid I would lose to much data.
You can use blockproc() to get the histogram if you want to move along and do it for rectangles that cover the entire picture. If you want just a few irregularly-shaped regions then you'll have to do it "manually" using mask(s) for those regions.
You might try subsampling in the time dimension. Usually a frame of video is highly correlated with the previous and next several frames because the scene doesn't change much. So you can just take every nth frame.

Sign in to comment.

Tags

Asked:

on 23 Jan 2016

Commented:

on 24 Jan 2016

Community Treasure Hunt

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

Start Hunting!