Ejemplo n.º 1
0
def compress(path, output, c: model.Compression):
    rgb = cv2.imread(path)
    if c == model.Compression.JPEG:
        compressed = compression.jpeg_compression(rgb)
        hi = codec.jpeg_encode(compressed)
    elif c == model.Compression.HIC:
        compressed = compression.wavelet_compression(rgb)
        hi = codec.wavelet_encode(compressed)
    else:
        raise RuntimeError("Unknown compression type")
    output = os.path.join(output, img_name(path, c))
    hi.write_file(output)
Ejemplo n.º 2
0
    def test_gh_wavelet(self):
        rgb = cv2.imread("resources/gh.png")
        out = compression.wavelet_compression(rgb)
        h = codec.wavelet_encode(out)

        bites = h.byte_stream()

        retrieve = h.from_bytes(bites)
        loads = zip(h.payloads, retrieve.payloads)
        evals = []
        # inspect the cases
        for (i, z) in enumerate(loads):
            evals.append((z[0] == z[1], z[0], z[1]))

        for e in evals:
            self.assertTrue(e[0])
Ejemplo n.º 3
0
import cv2
from hiccup.compression import wavelet_compression, wavelet_decompression, jpeg_decompression, jpeg_compression
from hiccup.transform import salt_pepper

rgb = cv2.imread("../../resources/Lenna.png")
rgb = salt_pepper(rgb)

out = wavelet_compression(rgb)
jout = jpeg_compression(rgb)
cv2.imshow("before", rgb)
res = wavelet_decompression(out)
jres = jpeg_decompression(jout)
cv2.imshow("after wave", res)
cv2.imshow("after jpeg", jres)
cv2.waitKey()
Ejemplo n.º 4
0
 def f():
     compressed = compression.wavelet_compression(i)
     codec.wavelet_encode(compressed)