-
Notifications
You must be signed in to change notification settings - Fork 175
Description
There are three bugs reported as following:
-
Color displays not accurate

The exact color value are printed at console. And the displayed color value could be captured by screen cut-shot are marked at in the image.
It seems that ASAP displays a inaccurate color value. -
API at "./bin/multiresolutionimageinterface.py" are not well supported.
I encapsulated a tool based on this interface at this page jassor/utils/writer_asap.py.
Then I found that not all optional parameters in the interface are available:
# Register LUT in _multiresolutionimageinterface:
_multiresolutionimageinterface.LUT_swigregister(LUT)
ColorType_InvalidColorType = _multiresolutionimageinterface.ColorType_InvalidColorType
ColorType_Monochrome = _multiresolutionimageinterface.ColorType_Monochrome
ColorType_RGB = _multiresolutionimageinterface.ColorType_RGB
ColorType_RGBA = _multiresolutionimageinterface.ColorType_RGBA
ColorType_Indexed = _multiresolutionimageinterface.ColorType_Indexed
DataType_InvalidDataType = _multiresolutionimageinterface.DataType_InvalidDataType
DataType_UChar = _multiresolutionimageinterface.DataType_UChar
DataType_UInt16 = _multiresolutionimageinterface.DataType_UInt16
DataType_UInt32 = _multiresolutionimageinterface.DataType_UInt32
DataType_Float = _multiresolutionimageinterface.DataType_Float
Compression_RAW = _multiresolutionimageinterface.Compression_RAW
Compression_JPEG = _multiresolutionimageinterface.Compression_JPEG
Compression_LZW = _multiresolutionimageinterface.Compression_LZW
Compression_JPEG2000 = _multiresolutionimageinterface.Compression_JPEG2000
Interpolation_NearestNeighbor = _multiresolutionimageinterface.Interpolation_NearestNeighbor
Interpolation_Linear = _multiresolutionimageinterface.Interpolation_Linear
Only "color_type in [Monochrome, RGB, RGBA]" and "data_type==UChar" are available.
While I am trying to use "color_type==Indexed", I got this exit code: " Process finished with exit code -1073741819 (0xC0000005) "
Similarly, use "data_type==UInt16" may get the same exit code.
All bug with exit code will kill process immediately —— by cpp process —— and can not by caught anyway in python code.
Here are my test codes running with version "pip install jassor==0.6.3".
import jassor.utils as J
from jassor.components import data
import numpy as np
def main():
path = rf'./test.tif'
k = 512
w = 2048
h = 1024
# color_type in ['INVALID', 'MONOCHROME', 'RGB', 'RGBA', 'INDEXED']
# data_type in ['INVALID', 'UCHAR', 'UINT16', 'UINT32', 'FLOAT']
# compression in ['RAW', 'JPEG', 'LZW', 'JPEG2000']
# interpolation in ['LINEAR', 'NEAREST']
with J.SlideWriter(
output_path=path,
tile_size=k,
dimensions=(w, h),
spacing=1,
color_type='MONOCHROME',
data_type='UINT16',
compression='LZW',
interpolation='NEAREST',
) as writer:
for y in range(0, h, k):
for x in range(0, w, k):
patch = random_patch(k, 4, 255, np.uint8)[:, :, 0]
print(f'color_{x}_{y}:{patch[0, 0]}')
writer.write(patch, x, y)
image = data.load(path)
J.plot(image.thumb())
def random_patch(patch_size: int, channel: int, max_value: int, dtype: type):
basic = np.ones((patch_size, patch_size, 1))
color = np.random.random(channel)[None, None, :]
patch = basic * (color * max_value).round().astype(int)
return patch.astype(dtype)
if __name__ == '__main__':
main()
- The ordering of different settings could also has influence on bug. (maybe not bug? I don't know why.)
# group 1
self._writer.setColorType(color_type_map[color_type.upper()])
self._writer.setDataType(data_type_map[data_type.upper()])
self._writer.setCompression(compression_map[compression.upper()])
self._writer.setInterpolation(interpolation_map[interpolation.upper()])
# group 2
self._writer.setTileSize(self.tile_size)
self._writer.writeImageInformation(self.W, self.H)
pixel_size_vec = mir.vector_double()
pixel_size_vec.push_back(self.spacing)
pixel_size_vec.push_back(self.spacing)
self._writer.setSpacing(pixel_size_vec)
Exchange the order of group 1 and group 2 can also cause bug exit code.