Changed nemo.jp2 to only have a single tile
This commit is contained in:
parent
243e23f4e2
commit
933cddf057
6 changed files with 65 additions and 82 deletions
Binary file not shown.
|
|
@ -203,7 +203,7 @@ class Jp2k(Jp2kBox):
|
||||||
>>> import glymur
|
>>> import glymur
|
||||||
>>> jfile = glymur.data.nemo()
|
>>> jfile = glymur.data.nemo()
|
||||||
>>> jp2 = glymur.Jp2k(jfile)
|
>>> jp2 = glymur.Jp2k(jfile)
|
||||||
>>> data = jp2.read(reduce=3)
|
>>> data = jp2.read(reduce=1)
|
||||||
>>> from tempfile import NamedTemporaryFile
|
>>> from tempfile import NamedTemporaryFile
|
||||||
>>> tfile = NamedTemporaryFile(suffix='.jp2', delete=False)
|
>>> tfile = NamedTemporaryFile(suffix='.jp2', delete=False)
|
||||||
>>> j = Jp2k(tfile.name, mode='wb')
|
>>> j = Jp2k(tfile.name, mode='wb')
|
||||||
|
|
@ -587,7 +587,7 @@ class Jp2k(Jp2kBox):
|
||||||
|
|
||||||
>>> thumbnail = jp.read(reduce=-1)
|
>>> thumbnail = jp.read(reduce=-1)
|
||||||
>>> thumbnail.shape
|
>>> thumbnail.shape
|
||||||
(46, 81, 3)
|
(728, 1296, 3)
|
||||||
"""
|
"""
|
||||||
if opj2._OPENJP2 is not None:
|
if opj2._OPENJP2 is not None:
|
||||||
img_array = self._read_openjp2(**kwargs)
|
img_array = self._read_openjp2(**kwargs)
|
||||||
|
|
@ -930,14 +930,14 @@ class Jp2k(Jp2kBox):
|
||||||
--------
|
--------
|
||||||
>>> import glymur
|
>>> import glymur
|
||||||
>>> jfile = glymur.data.nemo()
|
>>> jfile = glymur.data.nemo()
|
||||||
>>> jp = glymur.Jp2k(jfile)
|
>>> jp2 = glymur.Jp2k(jfile)
|
||||||
>>> codestream = jp.get_codestream()
|
>>> codestream = jp2.get_codestream()
|
||||||
>>> print(codestream.segment[1])
|
>>> print(codestream.segment[1])
|
||||||
SIZ marker segment @ (3137, 47)
|
SIZ marker segment @ (3137, 47)
|
||||||
Profile: 2
|
Profile: 2
|
||||||
Reference Grid Height, Width: (1456 x 2592)
|
Reference Grid Height, Width: (1456 x 2592)
|
||||||
Vertical, Horizontal Reference Grid Offset: (0 x 0)
|
Vertical, Horizontal Reference Grid Offset: (0 x 0)
|
||||||
Reference Tile Height, Width: (512 x 512)
|
Reference Tile Height, Width: (1456 x 2592)
|
||||||
Vertical, Horizontal Reference Tile Offset: (0 x 0)
|
Vertical, Horizontal Reference Tile Offset: (0 x 0)
|
||||||
Bitdepth: (8, 8, 8)
|
Bitdepth: (8, 8, 8)
|
||||||
Signed: (False, False, False)
|
Signed: (False, False, False)
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ class TestCallbacks(unittest.TestCase):
|
||||||
# Save sys.stdout.
|
# Save sys.stdout.
|
||||||
self.stdout = sys.stdout
|
self.stdout = sys.stdout
|
||||||
sys.stdout = StringIO()
|
sys.stdout = StringIO()
|
||||||
self.jp2file = pkg_resources.resource_filename(glymur.__name__,
|
self.jp2file = glymur.data.nemo()
|
||||||
"data/nemo.jp2")
|
self.j2kfile = glymur.data.goodstuff()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
# Restore stdout.
|
# Restore stdout.
|
||||||
|
|
@ -44,20 +44,16 @@ class TestCallbacks(unittest.TestCase):
|
||||||
def test_info_warning_callbacks_on_read(self):
|
def test_info_warning_callbacks_on_read(self):
|
||||||
# Verify that we get the expected stdio output when our internal info
|
# Verify that we get the expected stdio output when our internal info
|
||||||
# callback handler is enabled.
|
# callback handler is enabled.
|
||||||
j = glymur.Jp2k(self.jp2file)
|
j = glymur.Jp2k(self.j2kfile)
|
||||||
d = j.read(reduce=3, verbose=True, area=(0, 0, 512, 1024))
|
d = j.read(reduce=1, verbose=True, area=(0, 0, 200, 150))
|
||||||
actual = sys.stdout.getvalue().strip()
|
actual = sys.stdout.getvalue().strip()
|
||||||
|
|
||||||
lines = ['[INFO] Start to read j2k main header (3135).',
|
lines = ['[INFO] Start to read j2k main header (0).',
|
||||||
'[INFO] Main header has been correctly decoded.',
|
'[INFO] Main header has been correctly decoded.',
|
||||||
'[INFO] Setting decoding area to 0,0,1024,512',
|
'[INFO] Setting decoding area to 0,0,150,200',
|
||||||
'[INFO] Header of tile 0 / 17 has been read.',
|
'[INFO] Header of tile 0 / 0 has been read.',
|
||||||
'[INFO] Tile 1/18 has been decoded.',
|
'[INFO] Tile 1/1 has been decoded.',
|
||||||
'[INFO] Image data has been updated with tile 1.',
|
'[INFO] Image data has been updated with tile 1.']
|
||||||
'[INFO] Header of tile 1 / 17 has been read.',
|
|
||||||
'[INFO] Tile 2/18 has been decoded.',
|
|
||||||
'[INFO] Image data has been updated with tile 2.',
|
|
||||||
'[INFO] Stream reached its end !']
|
|
||||||
|
|
||||||
expected = '\n'.join(lines)
|
expected = '\n'.join(lines)
|
||||||
self.assertEqual(actual, expected)
|
self.assertEqual(actual, expected)
|
||||||
|
|
|
||||||
|
|
@ -74,10 +74,8 @@ class TestJp2k(unittest.TestCase):
|
||||||
os.unlink(cls._bad_xml_file)
|
os.unlink(cls._bad_xml_file)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.jp2file = pkg_resources.resource_filename(glymur.__name__,
|
self.jp2file = glymur.data.nemo()
|
||||||
"data/nemo.jp2")
|
self.j2kfile = glymur.data.goodstuff()
|
||||||
self.j2kfile = pkg_resources.resource_filename(glymur.__name__,
|
|
||||||
"data/goodstuff.j2k")
|
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
pass
|
pass
|
||||||
|
|
@ -92,11 +90,11 @@ class TestJp2k(unittest.TestCase):
|
||||||
|
|
||||||
def test_reduce_max(self):
|
def test_reduce_max(self):
|
||||||
# Verify that reduce=-1 gets us the lowest resolution image
|
# Verify that reduce=-1 gets us the lowest resolution image
|
||||||
j = Jp2k(self.jp2file)
|
j = Jp2k(self.j2kfile)
|
||||||
thumbnail1 = j.read(reduce=-1)
|
thumbnail1 = j.read(reduce=-1)
|
||||||
thumbnail2 = j.read(reduce=5)
|
thumbnail2 = j.read(reduce=5)
|
||||||
np.testing.assert_array_equal(thumbnail1, thumbnail2)
|
np.testing.assert_array_equal(thumbnail1, thumbnail2)
|
||||||
self.assertEqual(thumbnail1.shape, (46, 81, 3))
|
self.assertEqual(thumbnail1.shape, (25, 15, 3))
|
||||||
|
|
||||||
def test_invalid_xml_box(self):
|
def test_invalid_xml_box(self):
|
||||||
# Should be able to recover from xml box with bad xml.
|
# Should be able to recover from xml box with bad xml.
|
||||||
|
|
@ -145,15 +143,6 @@ class TestJp2k(unittest.TestCase):
|
||||||
filename = 'this file does not actually exist on the file system.'
|
filename = 'this file does not actually exist on the file system.'
|
||||||
jp2k = Jp2k(filename)
|
jp2k = Jp2k(filename)
|
||||||
|
|
||||||
def test_nemo_tile(self):
|
|
||||||
# Issue 134, trouble reading first nemo tile.
|
|
||||||
j = Jp2k(self.jp2file)
|
|
||||||
with warnings.catch_warnings():
|
|
||||||
warnings.simplefilter("ignore")
|
|
||||||
tiledata = j.read(tile=0)
|
|
||||||
subsetdata = j.read(area=(0, 0, 512, 512))
|
|
||||||
np.testing.assert_array_equal(tiledata, subsetdata)
|
|
||||||
|
|
||||||
def test_write_srgb_without_mct(self):
|
def test_write_srgb_without_mct(self):
|
||||||
j2k = Jp2k(self.j2kfile)
|
j2k = Jp2k(self.j2kfile)
|
||||||
expdata = j2k.read()
|
expdata = j2k.read()
|
||||||
|
|
@ -178,7 +167,7 @@ class TestJp2k(unittest.TestCase):
|
||||||
def test_write_cprl(self):
|
def test_write_cprl(self):
|
||||||
# Issue 17
|
# Issue 17
|
||||||
j = Jp2k(self.jp2file)
|
j = Jp2k(self.jp2file)
|
||||||
expdata = j.read(reduce=2)
|
expdata = j.read(reduce=1)
|
||||||
with tempfile.NamedTemporaryFile(suffix='.jp2') as tfile:
|
with tempfile.NamedTemporaryFile(suffix='.jp2') as tfile:
|
||||||
ofile = Jp2k(tfile.name, 'wb')
|
ofile = Jp2k(tfile.name, 'wb')
|
||||||
ofile.write(expdata, prog='CPRL')
|
ofile.write(expdata, prog='CPRL')
|
||||||
|
|
@ -220,7 +209,7 @@ class TestJp2k(unittest.TestCase):
|
||||||
|
|
||||||
self.assertEqual(jp2k.box[5].id, 'jp2c')
|
self.assertEqual(jp2k.box[5].id, 'jp2c')
|
||||||
self.assertEqual(jp2k.box[5].offset, 3127)
|
self.assertEqual(jp2k.box[5].offset, 3127)
|
||||||
self.assertEqual(jp2k.box[5].length, 1133427)
|
self.assertEqual(jp2k.box[5].length, 1132296)
|
||||||
|
|
||||||
# jp2h super box
|
# jp2h super box
|
||||||
self.assertEqual(len(jp2k.box[2].box), 2)
|
self.assertEqual(len(jp2k.box[2].box), 2)
|
||||||
|
|
@ -540,7 +529,7 @@ class TestJp2k(unittest.TestCase):
|
||||||
def test_asoc_label_box(self):
|
def test_asoc_label_box(self):
|
||||||
# Construct a fake file with an asoc and a label box, as
|
# Construct a fake file with an asoc and a label box, as
|
||||||
# OpenJPEG doesn't have such a file.
|
# OpenJPEG doesn't have such a file.
|
||||||
data = Jp2k(self.jp2file).read(reduce=3)
|
data = Jp2k(self.jp2file).read(reduce=1)
|
||||||
with tempfile.NamedTemporaryFile(suffix='.jp2') as tfile:
|
with tempfile.NamedTemporaryFile(suffix='.jp2') as tfile:
|
||||||
j = Jp2k(tfile.name, 'wb')
|
j = Jp2k(tfile.name, 'wb')
|
||||||
j.write(data)
|
j.write(data)
|
||||||
|
|
|
||||||
|
|
@ -65,8 +65,8 @@ def read_image(infile):
|
||||||
class TestSuiteNegative(unittest.TestCase):
|
class TestSuiteNegative(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.jp2file = pkg_resources.resource_filename(glymur.__name__,
|
self.jp2file = glymur.data.nemo()
|
||||||
"data/nemo.jp2")
|
self.j2kfile = glymur.data.goodstuff()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
pass
|
pass
|
||||||
|
|
@ -156,8 +156,8 @@ class TestSuiteNegative(unittest.TestCase):
|
||||||
|
|
||||||
def test_precinct_size_not_multiple_of_two(self):
|
def test_precinct_size_not_multiple_of_two(self):
|
||||||
# Seems like precinct sizes should be powers of two.
|
# Seems like precinct sizes should be powers of two.
|
||||||
ifile = Jp2k(self.jp2file)
|
ifile = Jp2k(self.j2kfile)
|
||||||
data = ifile.read(reduce=3)
|
data = ifile.read(reduce=2)
|
||||||
with tempfile.NamedTemporaryFile(suffix='.jp2') as tfile:
|
with tempfile.NamedTemporaryFile(suffix='.jp2') as tfile:
|
||||||
ofile = Jp2k(tfile.name, 'wb')
|
ofile = Jp2k(tfile.name, 'wb')
|
||||||
with self.assertRaises(IOError) as ce:
|
with self.assertRaises(IOError) as ce:
|
||||||
|
|
@ -165,8 +165,8 @@ class TestSuiteNegative(unittest.TestCase):
|
||||||
|
|
||||||
def test_codeblock_size_not_multiple_of_two(self):
|
def test_codeblock_size_not_multiple_of_two(self):
|
||||||
# Seems like code block sizes should be powers of two.
|
# Seems like code block sizes should be powers of two.
|
||||||
ifile = Jp2k(self.jp2file)
|
ifile = Jp2k(self.j2kfile)
|
||||||
data = ifile.read(reduce=3)
|
data = ifile.read(reduce=2)
|
||||||
with tempfile.NamedTemporaryFile(suffix='.jp2') as tfile:
|
with tempfile.NamedTemporaryFile(suffix='.jp2') as tfile:
|
||||||
ofile = Jp2k(tfile.name, 'wb')
|
ofile = Jp2k(tfile.name, 'wb')
|
||||||
with self.assertRaises(IOError) as ce:
|
with self.assertRaises(IOError) as ce:
|
||||||
|
|
@ -175,8 +175,8 @@ class TestSuiteNegative(unittest.TestCase):
|
||||||
def test_codeblock_size_with_precinct_size(self):
|
def test_codeblock_size_with_precinct_size(self):
|
||||||
# Seems like code block sizes should never exceed half that of
|
# Seems like code block sizes should never exceed half that of
|
||||||
# precinct size.
|
# precinct size.
|
||||||
ifile = Jp2k(self.jp2file)
|
ifile = Jp2k(self.j2kfile)
|
||||||
data = ifile.read(reduce=3)
|
data = ifile.read(reduce=2)
|
||||||
with tempfile.NamedTemporaryFile(suffix='.jp2') as tfile:
|
with tempfile.NamedTemporaryFile(suffix='.jp2') as tfile:
|
||||||
ofile = Jp2k(tfile.name, 'wb')
|
ofile = Jp2k(tfile.name, 'wb')
|
||||||
with self.assertRaises(IOError) as ce:
|
with self.assertRaises(IOError) as ce:
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ class TestPrintingNeedsLib(unittest.TestCase):
|
||||||
with tempfile.NamedTemporaryFile(suffix='.jp2', delete=False) as tfile:
|
with tempfile.NamedTemporaryFile(suffix='.jp2', delete=False) as tfile:
|
||||||
cls._plain_nemo_file = tfile.name
|
cls._plain_nemo_file = tfile.name
|
||||||
ijfile = Jp2k(jp2file)
|
ijfile = Jp2k(jp2file)
|
||||||
data = ijfile.read(reduce=3)
|
data = ijfile.read(reduce=1)
|
||||||
ojfile = Jp2k(cls._plain_nemo_file, 'wb')
|
ojfile = Jp2k(cls._plain_nemo_file, 'wb')
|
||||||
ojfile.write(data)
|
ojfile.write(data)
|
||||||
|
|
||||||
|
|
@ -43,8 +43,9 @@ class TestPrintingNeedsLib(unittest.TestCase):
|
||||||
os.unlink(cls._plain_nemo_file)
|
os.unlink(cls._plain_nemo_file)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.jp2file = pkg_resources.resource_filename(glymur.__name__,
|
self.jp2file = glymur.data.nemo()
|
||||||
"data/nemo.jp2")
|
self.j2kfile = glymur.data.goodstuff()
|
||||||
|
|
||||||
# Save sys.stdout.
|
# Save sys.stdout.
|
||||||
self.stdout = sys.stdout
|
self.stdout = sys.stdout
|
||||||
sys.stdout = StringIO()
|
sys.stdout = StringIO()
|
||||||
|
|
@ -57,7 +58,7 @@ class TestPrintingNeedsLib(unittest.TestCase):
|
||||||
" Compatibility: ['jp2 ']",
|
" Compatibility: ['jp2 ']",
|
||||||
'JP2 Header Box (jp2h) @ (32, 45)',
|
'JP2 Header Box (jp2h) @ (32, 45)',
|
||||||
' Image Header Box (ihdr) @ (40, 22)',
|
' Image Header Box (ihdr) @ (40, 22)',
|
||||||
' Size: [182 324 3]',
|
' Size: [728 1296 3]',
|
||||||
' Bitdepth: 8',
|
' Bitdepth: 8',
|
||||||
' Signed: False',
|
' Signed: False',
|
||||||
' Compression: wavelet',
|
' Compression: wavelet',
|
||||||
|
|
@ -66,15 +67,15 @@ class TestPrintingNeedsLib(unittest.TestCase):
|
||||||
' Method: enumerated colorspace',
|
' Method: enumerated colorspace',
|
||||||
' Precedence: 0',
|
' Precedence: 0',
|
||||||
' Colorspace: sRGB',
|
' Colorspace: sRGB',
|
||||||
'Contiguous Codestream Box (jp2c) @ (77, 112814)',
|
'Contiguous Codestream Box (jp2c) @ (77, 1632355)',
|
||||||
' Main header:',
|
' Main header:',
|
||||||
' SOC marker segment @ (85, 0)',
|
' SOC marker segment @ (85, 0)',
|
||||||
' SIZ marker segment @ (87, 47)',
|
' SIZ marker segment @ (87, 47)',
|
||||||
' Profile: 2',
|
' Profile: 2',
|
||||||
' Reference Grid Height, Width: (182 x 324)',
|
' Reference Grid Height, Width: (728 x 1296)',
|
||||||
' Vertical, Horizontal Reference Grid Offset: '
|
' Vertical, Horizontal Reference Grid Offset: '
|
||||||
+ '(0 x 0)',
|
+ '(0 x 0)',
|
||||||
' Reference Tile Height, Width: (182 x 324)',
|
' Reference Tile Height, Width: (728 x 1296)',
|
||||||
' Vertical, Horizontal Reference Tile Offset: '
|
' Vertical, Horizontal Reference Tile Offset: '
|
||||||
+ '(0 x 0)',
|
+ '(0 x 0)',
|
||||||
' Bitdepth: (8, 8, 8)',
|
' Bitdepth: (8, 8, 8)',
|
||||||
|
|
@ -121,7 +122,7 @@ class TestPrintingNeedsLib(unittest.TestCase):
|
||||||
def test_asoc_label_box(self):
|
def test_asoc_label_box(self):
|
||||||
# Construct a fake file with an asoc and a label box, as
|
# Construct a fake file with an asoc and a label box, as
|
||||||
# OpenJPEG doesn't have such a file.
|
# OpenJPEG doesn't have such a file.
|
||||||
data = glymur.Jp2k(self.jp2file).read(reduce=3)
|
data = glymur.Jp2k(self.jp2file).read(reduce=1)
|
||||||
with tempfile.NamedTemporaryFile(suffix='.jp2') as tfile:
|
with tempfile.NamedTemporaryFile(suffix='.jp2') as tfile:
|
||||||
j = glymur.Jp2k(tfile.name, 'wb')
|
j = glymur.Jp2k(tfile.name, 'wb')
|
||||||
j.write(data)
|
j.write(data)
|
||||||
|
|
@ -177,7 +178,7 @@ class TestPrintingNeedsLib(unittest.TestCase):
|
||||||
lst = actual.split('\n')
|
lst = actual.split('\n')
|
||||||
lst = lst[1:]
|
lst = lst[1:]
|
||||||
actual = '\n'.join(lst)
|
actual = '\n'.join(lst)
|
||||||
|
self.maxDiff = None
|
||||||
self.assertEqual(actual, self.expectedPlain)
|
self.assertEqual(actual, self.expectedPlain)
|
||||||
|
|
||||||
def test_entire_file(self):
|
def test_entire_file(self):
|
||||||
|
|
@ -209,15 +210,15 @@ class TestPrinting(unittest.TestCase):
|
||||||
def test_COC_segment(self):
|
def test_COC_segment(self):
|
||||||
j = glymur.Jp2k(self.jp2file)
|
j = glymur.Jp2k(self.jp2file)
|
||||||
codestream = j.get_codestream(header_only=False)
|
codestream = j.get_codestream(header_only=False)
|
||||||
print(codestream.segment[5])
|
print(codestream.segment[6])
|
||||||
actual = sys.stdout.getvalue().strip()
|
actual = sys.stdout.getvalue().strip()
|
||||||
|
|
||||||
lines = ['COC marker segment @ (3233, 9)',
|
lines = ['COC marker segment @ (3260, 9)',
|
||||||
' Associated component: 1',
|
' Associated component: 1',
|
||||||
' Coding style for this component: '
|
' Coding style for this component: '
|
||||||
+ 'Entropy coder, PARTITION = 0',
|
+ 'Entropy coder, PARTITION = 0',
|
||||||
' Coding style parameters:',
|
' Coding style parameters:',
|
||||||
' Number of resolutions: 6',
|
' Number of resolutions: 2',
|
||||||
' Code block height, width: (64 x 64)',
|
' Code block height, width: (64 x 64)',
|
||||||
' Wavelet transform: 5-3 reversible',
|
' Wavelet transform: 5-3 reversible',
|
||||||
' Code block context:',
|
' Code block context:',
|
||||||
|
|
@ -230,6 +231,7 @@ class TestPrinting(unittest.TestCase):
|
||||||
' Segmentation symbols: False']
|
' Segmentation symbols: False']
|
||||||
|
|
||||||
expected = '\n'.join(lines)
|
expected = '\n'.join(lines)
|
||||||
|
self.maxDiff = None
|
||||||
self.assertEqual(actual, expected)
|
self.assertEqual(actual, expected)
|
||||||
|
|
||||||
def test_COD_segment(self):
|
def test_COD_segment(self):
|
||||||
|
|
@ -245,10 +247,10 @@ class TestPrinting(unittest.TestCase):
|
||||||
' EPH marker segments: False',
|
' EPH marker segments: False',
|
||||||
' Coding style parameters:',
|
' Coding style parameters:',
|
||||||
' Progression order: LRCP',
|
' Progression order: LRCP',
|
||||||
' Number of layers: 3',
|
' Number of layers: 2',
|
||||||
' Multiple component transformation usage: '
|
' Multiple component transformation usage: '
|
||||||
+ 'reversible',
|
+ 'reversible',
|
||||||
' Number of resolutions: 6',
|
' Number of resolutions: 2',
|
||||||
' Code block height, width: (64 x 64)',
|
' Code block height, width: (64 x 64)',
|
||||||
' Wavelet transform: 5-3 reversible',
|
' Wavelet transform: 5-3 reversible',
|
||||||
' Precinct size: default, 2^15 x 2^15',
|
' Precinct size: default, 2^15 x 2^15',
|
||||||
|
|
@ -392,7 +394,7 @@ class TestPrinting(unittest.TestCase):
|
||||||
print(codestream.segment[-1])
|
print(codestream.segment[-1])
|
||||||
actual = sys.stdout.getvalue().strip()
|
actual = sys.stdout.getvalue().strip()
|
||||||
|
|
||||||
lines = ['EOC marker segment @ (1136552, 0)']
|
lines = ['EOC marker segment @ (1135421, 0)']
|
||||||
expected = '\n'.join(lines)
|
expected = '\n'.join(lines)
|
||||||
self.assertEqual(actual, expected)
|
self.assertEqual(actual, expected)
|
||||||
|
|
||||||
|
|
@ -476,15 +478,13 @@ class TestPrinting(unittest.TestCase):
|
||||||
def test_QCC_segment(self):
|
def test_QCC_segment(self):
|
||||||
j = glymur.Jp2k(self.jp2file)
|
j = glymur.Jp2k(self.jp2file)
|
||||||
codestream = j.get_codestream(header_only=False)
|
codestream = j.get_codestream(header_only=False)
|
||||||
print(codestream.segment[6])
|
print(codestream.segment[7])
|
||||||
actual = sys.stdout.getvalue().strip()
|
actual = sys.stdout.getvalue().strip()
|
||||||
|
|
||||||
lines = ['QCC marker segment @ (3244, 20)',
|
lines = ['QCC marker segment @ (3271, 8)',
|
||||||
' Associated Component: 1',
|
' Associated Component: 1',
|
||||||
' Quantization style: no quantization, 2 guard bits',
|
' Quantization style: no quantization, 2 guard bits',
|
||||||
' Step size: [(0, 8), (0, 9), (0, 9), (0, 10), (0, 9), '
|
' Step size: [(0, 8), (0, 9), (0, 9), (0, 10)]']
|
||||||
+ '(0, 9), (0, 10), (0, 9), (0, 9), (0, 10), (0, 9), (0, 9), '
|
|
||||||
+ '(0, 10), (0, 9), (0, 9), (0, 10)]']
|
|
||||||
|
|
||||||
expected = '\n'.join(lines)
|
expected = '\n'.join(lines)
|
||||||
self.assertEqual(actual, expected)
|
self.assertEqual(actual, expected)
|
||||||
|
|
@ -495,11 +495,9 @@ class TestPrinting(unittest.TestCase):
|
||||||
print(codestream.segment[3])
|
print(codestream.segment[3])
|
||||||
actual = sys.stdout.getvalue().strip()
|
actual = sys.stdout.getvalue().strip()
|
||||||
|
|
||||||
lines = ['QCD marker segment @ (3200, 19)',
|
lines = ['QCD marker segment @ (3200, 7)',
|
||||||
' Quantization style: no quantization, 2 guard bits',
|
' Quantization style: no quantization, 2 guard bits',
|
||||||
' Step size: [(0, 8), (0, 9), (0, 9), (0, 10), (0, 9), '
|
' Step size: [(0, 8), (0, 9), (0, 9), (0, 10)]']
|
||||||
+ '(0, 9), (0, 10), (0, 9), (0, 9), (0, 10), (0, 9), '
|
|
||||||
+ '(0, 9), (0, 10), (0, 9), (0, 9), (0, 10)]']
|
|
||||||
|
|
||||||
expected = '\n'.join(lines)
|
expected = '\n'.join(lines)
|
||||||
self.assertEqual(actual, expected)
|
self.assertEqual(actual, expected)
|
||||||
|
|
@ -514,7 +512,7 @@ class TestPrinting(unittest.TestCase):
|
||||||
' Profile: 2',
|
' Profile: 2',
|
||||||
' Reference Grid Height, Width: (1456 x 2592)',
|
' Reference Grid Height, Width: (1456 x 2592)',
|
||||||
' Vertical, Horizontal Reference Grid Offset: (0 x 0)',
|
' Vertical, Horizontal Reference Grid Offset: (0 x 0)',
|
||||||
' Reference Tile Height, Width: (512 x 512)',
|
' Reference Tile Height, Width: (1456 x 2592)',
|
||||||
' Vertical, Horizontal Reference Tile Offset: (0 x 0)',
|
' Vertical, Horizontal Reference Tile Offset: (0 x 0)',
|
||||||
' Bitdepth: (8, 8, 8)',
|
' Bitdepth: (8, 8, 8)',
|
||||||
' Signed: (False, False, False)',
|
' Signed: (False, False, False)',
|
||||||
|
|
@ -537,26 +535,27 @@ class TestPrinting(unittest.TestCase):
|
||||||
def test_SOD_segment(self):
|
def test_SOD_segment(self):
|
||||||
j = glymur.Jp2k(self.jp2file)
|
j = glymur.Jp2k(self.jp2file)
|
||||||
codestream = j.get_codestream(header_only=False)
|
codestream = j.get_codestream(header_only=False)
|
||||||
print(codestream.segment[9])
|
print(codestream.segment[10])
|
||||||
actual = sys.stdout.getvalue().strip()
|
actual = sys.stdout.getvalue().strip()
|
||||||
|
|
||||||
lines = ['SOD marker segment @ (3299, 0)']
|
lines = ['SOD marker segment @ (3302, 0)']
|
||||||
expected = '\n'.join(lines)
|
expected = '\n'.join(lines)
|
||||||
self.assertEqual(actual, expected)
|
self.assertEqual(actual, expected)
|
||||||
|
|
||||||
def test_SOT_segment(self):
|
def test_SOT_segment(self):
|
||||||
j = glymur.Jp2k(self.jp2file)
|
j = glymur.Jp2k(self.jp2file)
|
||||||
codestream = j.get_codestream(header_only=False)
|
codestream = j.get_codestream(header_only=False)
|
||||||
print(codestream.segment[4])
|
print(codestream.segment[5])
|
||||||
actual = sys.stdout.getvalue().strip()
|
actual = sys.stdout.getvalue().strip()
|
||||||
|
|
||||||
lines = ['SOT marker segment @ (3221, 10)',
|
lines = ['SOT marker segment @ (3248, 10)',
|
||||||
' Tile part index: 0',
|
' Tile part index: 0',
|
||||||
' Tile part length: 78629',
|
' Tile part length: 1132173',
|
||||||
' Tile part instance: 0',
|
' Tile part instance: 0',
|
||||||
' Number of tile parts: 1']
|
' Number of tile parts: 1']
|
||||||
|
|
||||||
expected = '\n'.join(lines)
|
expected = '\n'.join(lines)
|
||||||
|
self.maxDiff = None
|
||||||
self.assertEqual(actual, expected)
|
self.assertEqual(actual, expected)
|
||||||
|
|
||||||
@unittest.skipIf(data_root is None,
|
@unittest.skipIf(data_root is None,
|
||||||
|
|
@ -606,7 +605,7 @@ class TestPrinting(unittest.TestCase):
|
||||||
' Profile: 2',
|
' Profile: 2',
|
||||||
' Reference Grid Height, Width: (1456 x 2592)',
|
' Reference Grid Height, Width: (1456 x 2592)',
|
||||||
' Vertical, Horizontal Reference Grid Offset: (0 x 0)',
|
' Vertical, Horizontal Reference Grid Offset: (0 x 0)',
|
||||||
' Reference Tile Height, Width: (512 x 512)',
|
' Reference Tile Height, Width: (1456 x 2592)',
|
||||||
' Vertical, Horizontal Reference Tile Offset: (0 x 0)',
|
' Vertical, Horizontal Reference Tile Offset: (0 x 0)',
|
||||||
' Bitdepth: (8, 8, 8)',
|
' Bitdepth: (8, 8, 8)',
|
||||||
' Signed: (False, False, False)',
|
' Signed: (False, False, False)',
|
||||||
|
|
@ -619,10 +618,10 @@ class TestPrinting(unittest.TestCase):
|
||||||
' EPH marker segments: False',
|
' EPH marker segments: False',
|
||||||
' Coding style parameters:',
|
' Coding style parameters:',
|
||||||
' Progression order: LRCP',
|
' Progression order: LRCP',
|
||||||
' Number of layers: 3',
|
' Number of layers: 2',
|
||||||
' Multiple component transformation usage: '
|
' Multiple component transformation usage: '
|
||||||
+ 'reversible',
|
+ 'reversible',
|
||||||
' Number of resolutions: 6',
|
' Number of resolutions: 2',
|
||||||
' Code block height, width: (64 x 64)',
|
' Code block height, width: (64 x 64)',
|
||||||
' Wavelet transform: 5-3 reversible',
|
' Wavelet transform: 5-3 reversible',
|
||||||
' Precinct size: default, 2^15 x 2^15',
|
' Precinct size: default, 2^15 x 2^15',
|
||||||
|
|
@ -634,13 +633,12 @@ class TestPrinting(unittest.TestCase):
|
||||||
' Vertically stripe causal context: False',
|
' Vertically stripe causal context: False',
|
||||||
' Predictable termination: False',
|
' Predictable termination: False',
|
||||||
' Segmentation symbols: False',
|
' Segmentation symbols: False',
|
||||||
' QCD marker segment @ (3200, 19)',
|
' QCD marker segment @ (3200, 7)',
|
||||||
' Quantization style: no quantization, '
|
' Quantization style: no quantization, '
|
||||||
+ '2 guard bits',
|
+ '2 guard bits',
|
||||||
' Step size: [(0, 8), (0, 9), (0, 9), '
|
' Step size: [(0, 8), (0, 9), (0, 9), (0, 10)]',
|
||||||
+ '(0, 10), (0, 9), (0, 9), (0, 10), (0, 9), (0, 9), '
|
' CME marker segment @ (3209, 37)',
|
||||||
+ '(0, 10), (0, 9), (0, 9), (0, 10), (0, 9), (0, 9), '
|
' "Created by OpenJPEG version 2.0.0"']
|
||||||
+ '(0, 10)]']
|
|
||||||
expected = '\n'.join(lst)
|
expected = '\n'.join(lst)
|
||||||
self.assertEqual(actual, expected)
|
self.assertEqual(actual, expected)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue