histogram in database
I compute histogram for image(code below)
def compute_histogram_rgb(src, r_bins = 32, g_bins = 32, b_bins= 32):
#create planes
rplane = cv.CreateImage(cv.GetSize(src), 8, 1)
gplane = cv.CreateImage(cv.GetSize(src), 8, 1)
bplane = cv.CreateImage(cv.GetSize(src), 8, 1)
planes = [rplane, gplane, bplane]
cv.Split(src, rplane, gplane, bplane, None)
#compute histogram
hist = cv.CreateHist((r_bins, g_bins, b_bins), cv.CV_HIST_ARRAY,
ranges = ((0, 255),(0, 255), (0, 255)), uniform = True)
cv.CalcHist(planes, hist) #compute histogram
cv.NormalizeHist(hist, 1.0) #normalize hist
return hist
and then I want to store histogram in database (sqllite3 in python) but I don't know what format histogram is, do I need to unwrap it to vector?
it would get much easier using the cv2 instead of the cv api, since it would be a simple numpy array then, which is easy to serialize as a 'blob' in sqlite3
cv2 is more complicated, do you have any example with numpy array?