Beispiel #1
0
def spiht_image_pack(img, wavename, level, bpp, mode = "bi.orth", delta = 0.01, display_progress = True, str_pr = "", d = {}, handle = True):
    if not isinstance(img,tuple):
        img = (img)
        bpp = (bpp)
    ch_stream = {
            "size": 0,
            "channels":len(img),
            "bpp":bpp,
            "quant_delta":delta,
            "wave_type": wavename,
            "mode":mode,
            "decomp_level":level,
            "wise_bit":[],
            "payload":[]
            }
    for i in range(len(img)):
        m = np.asarray(img[i])
        if mode == "bi.orth":
            w = wavename(m,level,False)
        else:
            w = dwt.dwt2(m,wavename,level,mode)
        stream = spiht_pack(w,bpp[i],delta,display_progress,str_pr + "[channel "+str(i)+"]",d,handle)
        ch_stream["payload"] += stream["payload"]
        ch_stream["wave_type"] = w.name
        ch_stream["size"] += stream["size"]
        ch_stream["wise_bit"] += [stream["wise_bit"]]
        ch_stream["rows"] = stream["rows"]
        ch_stream["cols"] = stream["cols"]
    return ch_stream
Beispiel #2
0
def spiht_image_unpack(frame, display_progress = True, str_pr = "", d = {}, handle = True):
    rgb = []
    for i in range(frame["channels"]):
        pack = {
            "rows":frame["rows"],
            "cols":frame["cols"],
            "channels": 1,
            "wave_type":frame["wave_type"],
            "bpp":frame["bpp"],
            "quant_delta":frame["quant_delta"],
            "decomp_level":frame["decomp_level"],
            "wise_bit":frame["wise_bit"][i],
            "payload":frame["payload"][i]
            }
        wave = spiht_unpack(pack,True,str_pr + "[channel "+str(i)+"]", d, handle)
        if frame["wave_type"] == 'cdf97':
            ch = icdf97(wave,False)
        elif frame["wave_type"] == 'cdf53':
            ch = icdf53(wave,False)
        else:
            ch = dwt.dwt2(wave,frame["wave_type"],frame["decomp_level"],frame["mode"])
        ch = ch - ch.min()
        ch = ch / ch.max() * 255
        ch_i = np.zeros((len(ch),len(ch[0])),np.uint8)
        ch_i[:] = ch
        rgb += [cv.fromarray(ch_i)]
    return tuple(rgb)
Beispiel #3
0
def fvht_image_pack(img, wavename, level, f_center, Lbpp, lbpp, alpha, c, gamma, mode = "bi.orth", delta = 0.01, display_progress = True, str_pr = "", d = {}, handle = True):
    if not isinstance(img,tuple):
        img = (img)
    ch_stream = {
            "size": 0,
            "channels":len(img),
            "bpp":Lbpp,
            "quant_delta":delta,
            "wave_type": wavename,
            "mode":mode,
            "decomp_level":level,
            "wise_bit":[],
            "Lbpp": Lbpp,
            "lbpp": lbpp,
            "alpha": "alpha",
            "c": c,
            "gamma": gamma,
            "fovea_center": f_center,
            "payload":[]
            }
    for i in range(len(img)):
        m = np.asarray(img[i])
        if mode == "bi.orth":
            w = wavename(m,level,False)
        else:
            w = dwt.dwt2(m,wavename,level,mode)
        stream = fvht_pack(w, f_center, Lbpp, lbpp, alpha, c, gamma, delta, display_progress,str_pr + "[channel "+str(i)+"]",d,handle)
        ch_stream["payload"] += stream["payload"]
        ch_stream["wave_type"] = w.name
        ch_stream["size"] += stream["size"]
        ch_stream["wise_bit"] += [stream["wise_bit"]]
        ch_stream["rows"] = stream["rows"]
        ch_stream["cols"] = stream["cols"]
        ch_stream["bits"] = stream["bits"]
    return ch_stream