Mercurial > hg > orthanc-tests
changeset 79:962274ebd797
test_raw_frame
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 07 Mar 2016 17:43:33 +0100 |
parents | b89af51797ff |
children | 8466dbfcb22b |
files | Database/Lena.png Database/LenaTwiceWithFragments.dcm Database/README.txt Tests/Tests.py |
diffstat | 4 files changed, 40 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/Database/README.txt Tue Jan 05 17:25:11 2016 +0100 +++ b/Database/README.txt Mon Mar 07 17:43:33 2016 +0100 @@ -67,6 +67,8 @@ - KarstenHilbertRF.dcm : From Karsten Hilbert <karsten.hilbert@gmx.net>. - Knee/* : From OsiriX, "KNEE" (sample of JPEG2000). - Knix/* : From OsiriX, "KNIX" (sample of lossless JPEG). +- Lena.png : Lena/Lenna test image (as downloaded from Wikipedia). MD5 = 814a0034f5549e957ee61360d87457e5 +- LenaTwiceWithFragments.dcm: One image with 2 JPEG frames containing Lena (from Orthanc) - MarekLatin2.dcm : From Marek Święcicki <mswiecicki@archimedic.pl>. - Multiframe.dcm : From GDCM, "images_of_interest/PHILIPS_Integris_H-8-MONO2-Multiframe.dcm" - Phenix/* : From OsiriX, "PHENIX" (sample of uncompressed data).
--- a/Tests/Tests.py Tue Jan 05 17:25:11 2016 +0100 +++ b/Tests/Tests.py Mon Mar 07 17:43:33 2016 +0100 @@ -1357,6 +1357,7 @@ self.assertTrue('store' in DoGet(_REMOTE, '/modalities/orthanctest')) self.assertTrue('store' in DoGet(_REMOTE, '/peers/peer')) self.assertTrue('matlab' in DoGet(_REMOTE, '/instances/%s/frames/0' % a)) + self.assertTrue('raw' in DoGet(_REMOTE, '/instances/%s/frames/0' % a)) self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/tools/nope')) self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/nope')) self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/nope/nope.html')) @@ -2761,3 +2762,40 @@ Check('1.2.840.10008.1.2', 'd54aed9f67a100984b42942cc2e9939b') Check('1.2.840.10008.1.2.4.90', None) # JPEG-2000 image, not supported Check('1.2.840.10008.1.2.4.91', None) # JPEG-2000 image, not supported + + + def test_raw_frame(self): + s = UploadInstance(_REMOTE, 'Issue22.dcm')['ID'] + self.assertEqual(24, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) + a = DoGet(_REMOTE, '/instances/%s/frames/0/raw' % s) + self.assertEqual(512 * 512 * 2, len(a)) + self.assertEqual(512 * 512 * 2, len(DoGet(_REMOTE, '/instances/%s/frames/23/raw' % s))) + self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/24/raw' % s)) + self.assertEqual('1914287dc4d958eca21fdaacfb3482fa', ComputeMD5(a)) + + s = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] + self.assertEqual(76, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) + self.assertEqual(186274, len(DoGet(_REMOTE, '/instances/%s/frames/0/raw' % s))) + self.assertEqual(189424, len(DoGet(_REMOTE, '/instances/%s/frames/75/raw' % s))) + self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/76/raw' % s)) + im = GetImage(_REMOTE, '/instances/%s/frames/0/raw' % s) + self.assertEqual("L", im.mode) + self.assertEqual(512, im.size[0]) + self.assertEqual(512, im.size[1]) + + # Test an image with 2 JPEG frames spread over multiple fragments + s = UploadInstance(_REMOTE, 'LenaTwiceWithFragments.dcm')['ID'] + self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) + a = DoGet(_REMOTE, '/instances/%s/frames/0/raw' % s) + b = DoGet(_REMOTE, '/instances/%s/frames/1/raw' % s) + self.assertEqual(69214, len(a)) + self.assertEqual(ComputeMD5(a), ComputeMD5(b)) + self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/2/raw' % s)) + im = GetImage(_REMOTE, '/instances/%s/frames/0/raw' % s) + self.assertEqual("RGB", im.mode) + self.assertEqual(512, im.size[0]) + self.assertEqual(512, im.size[1]) + im = GetImage(_REMOTE, '/instances/%s/frames/0/preview' % s) + self.assertEqual("RGB", im.mode) + self.assertEqual(512, im.size[0]) + self.assertEqual(512, im.size[1])