def decompress(path): hi = hic.HicImage.from_file(path) if hi.hic_type == model.Compression.JPEG: compressed = codec.jpeg_decode(hi) rgb = compression.jpeg_decompression(compressed) elif hi.hic_type == model.Compression.HIC: compressed = codec.wavelet_decode(hi) rgb = compression.wavelet_decompression(compressed) else: raise RuntimeError("Unknown compression type") cv2.imshow("Result", rgb) cv2.waitKey()
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()