예제 #1
0
    def test_gh_jpg(self):
        rgb = cv2.imread("resources/gh.png")
        out = compression.jpeg_compression(rgb)
        h = codec.jpeg_encode(out)

        bites = h.byte_stream()

        retrieve = h.from_bytes(bites)
        loads = zip(h.payloads, retrieve.payloads)
        for (i, z) in enumerate(loads):
            self.assertEqual(z[0], z[1], msg="Case %d" % i)
예제 #2
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)
예제 #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()
예제 #4
0
 def f():
     compressed = compression.jpeg_compression(i)
     codec.jpeg_encode(compressed)