Esempio n. 1
0
    def test_encode_uint16(self):
        data, meta = data_io.read(self.fname16)

        data_comp = jls.encode(data)

        msg = 'oops size={:d}'.format(data_comp.size)
        self.assertTrue(data_comp.size < 2740000, msg)
Esempio n. 2
0
    def test_encode_band_resid(self):
        data, meta = data_io.read(self.fname_resid)

        data = data.squeeze()
        data_comp = jls.encode(data)

        msg = 'oops size={:d}'.format(data_comp.size)
        self.assertTrue(data_comp.size < 24000, msg)
Esempio n. 3
0
    def test_encode_decode_compare_uint8(self):
        data, meta = data_io.read(self.fname)

        # Compress, decompress.
        data_comp = jls.encode(data)

        data_image = jls.decode(data_comp)

        diff = np.sum( (data.squeeze().astype(np.int) - data_image.astype(np.int))**2)
        self.assertTrue(diff == 0)
Esempio n. 4
0
    def test_read_header(self):
        data, meta = data_io.read(self.fname)
        data_comp = jls.encode(data)

        header = jls.CharLS._CharLS.read_header(data_comp)

        self.assertTrue(header['width'] == 2592)
        self.assertTrue(header['height'] == 1944)
        self.assertTrue(header['bitspersample'] == 8)
        self.assertTrue(header['bytesperline'] == 2592)
        self.assertTrue(header['components'] == 1)
        self.assertTrue(header['allowedlossyerror'] == 0)
        self.assertTrue(header['ilv'] == 0)
Esempio n. 5
0
import os

import data_io
import jpeg_ls

# Read in an image from an existing PNG file.
fname_img = 'test/gray_raw.png'
data_image = data_io.read_PIL(fname_img)

# This input image should be a numpy array.
print('\nData properties:')
print('Type:  {:s}'.format(data_image.dtype))
print('Shape: {:s}'.format(data_image.shape))

# Compress image data to a sequence of bytes.
data_buffer = jpeg_ls.encode(data_image)

# Sizes.
size_png = os.path.getsize(fname_img)

print('\nSize of uncompressed image data: {:n}'.format(len(data_image.tostring())))
print('Size of PNG encoded data file:   {:n}'.format(size_png))
print('Size of JPEG-LS encoded data:    {:n}'.format(len(data_buffer)))

# Decompress.
data_image_b = jpeg_ls.decode(data_buffer)

# Compare image data, before and after.
is_same = (data_image == data_image_b).all()
print('\nRestored data is identical to original? {:s}\n'.format(str(is_same)))
Esempio n. 6
0
import os

from . import data_io
import jpeg_ls

# Read in an image from an existing PNG file.
fname_img = 'test/gray_raw.png'
data_image = data_io.read_PIL(fname_img)

# This input image should be a numpy array.
print('\nData properties:')
print('Type:  {:s}'.format(data_image.dtype))
print('Shape: {:s}'.format(data_image.shape))

# Compress image data to a sequence of bytes.
data_buffer = jpeg_ls.encode(data_image)

# Sizes.
size_png = os.path.getsize(fname_img)

print('\nSize of uncompressed image data: {:n}'.format(
    len(data_image.tostring())))
print('Size of PNG encoded data file:   {:n}'.format(size_png))
print('Size of JPEG-LS encoded data:    {:n}'.format(len(data_buffer)))

# Decompress.
data_image_b = jpeg_ls.decode(data_buffer)

# Compare image data, before and after.
is_same = (data_image == data_image_b).all()
print('\nRestored data is identical to original? {:s}\n'.format(str(is_same)))