Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions jpeg_ls/CharLS.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def write(fname, data_image):

def encode(data_image):
"""
Encode grey-scale image via JPEG-LS using CharLS implementation.
Encode image via JPEG-LS using CharLS implementation.
"""

if data_image.dtype == np.uint16 and np.max(data_image) <= 255:
Expand All @@ -52,7 +52,7 @@ def encode(data_image):

def decode(data_buffer):
"""
Decode grey-scale image via JPEG-LS using CharLS implementation.
Decode image via JPEG-LS using CharLS implementation.
"""

data_image = _CharLS.decode(data_buffer)
Expand Down
16 changes: 10 additions & 6 deletions jpeg_ls/_CharLS.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ cdef JlsParameters build_parameters():

def encode(data_image):
"""
Encode grey-scale image via JPEG-LS using CharLS implementation.
Encode image via JPEG-LS using CharLS implementation.
"""

data_image = np.asarray(data_image)
Expand All @@ -131,7 +131,7 @@ def encode(data_image):
else:
num_bands = data_image.shape[2]

if num_bands != 1:
if num_bands > 3:
raise Exception('Invalid number of bands %s' % num_bands)


Expand All @@ -148,15 +148,19 @@ def encode(data_image):
info.width = num_samples
info.height = num_lines
info.components = num_bands
info.ilv = <interleavemode>0
if num_bands == 1:
info.ilv = <interleavemode>0
else:
info.ilv = <interleavemode>1


info.bytesperline = num_samples * Bpp
info.bytesperline = num_bands * num_samples * Bpp
info.bitspersample = max_bits

info.allowedlossyerror = 0

# Buffer to store compressed data results.
cdef size_t size_buffer = num_samples*num_lines*Bpp*2
cdef size_t size_buffer = num_bands*num_samples*num_lines*Bpp*2

data_buffer = np.zeros(size_buffer, dtype=np.uint8)
cdef char* data_buffer_ptr = <char*>np.PyArray_DATA(data_buffer)
Expand All @@ -169,7 +173,7 @@ def encode(data_image):
cdef size_t* size_work_ptr = &size_work

# Call encoder function.
cdef size_t size_data = num_samples*num_lines*Bpp
cdef size_t size_data = num_bands*num_samples*num_lines*Bpp
cdef JLS_ERROR err
err = JpegLsEncode(data_buffer_ptr, size_buffer, size_work_ptr,
data_image_ptr, size_data, info_ptr)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

extra_link_args = []

flag_MSVC = True # Set this flag to True if using Visual Studio.
flag_MSVC = False # Set this flag to True if using Visual Studio.
if flag_MSVC:
extra_compile_args = ['/EHsc']
else:
Expand All @@ -37,7 +37,7 @@
extra_link_args=extra_link_args)

# Do it.
version = '1.0.2'
version = '1.1.0'

setup(name='CharPyLS',
packages=find_packages(),
Expand Down