I found a great book about OpenCV application, called OpenCV for Secret Agents. Here are some interesting stuff from the book.
Python code for histogram intersection
def intersection (hist0, hist1):
assert len(hist0) == len(hist1),
'histogram lengths are mismatched'
result = 0
for i in range (len(hist0)):
result += min(hist0[i], hist1[i])
return result
For example, image A has 50% of pixels are black and 50% of pixels are white, image B has 100% pixels are black, then intersection = min(0.5, 1) + min(0.5, 0) = 0.5.
However, when we classify the images, it is hard to apply a single reference histogram to describe "luxury, indoor". Instead, we want to find the average similarity between a query histogram and a set of multiple reference histograms.
Typically, histograms are stored in sparse format. A sparse matrix contains mainly zeros. We will not store all the zeros individually, but instead store the ranges that are full of zeros.
No comments:
Post a Comment