Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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?