當前位置: 首頁>>代碼示例>>Python>>正文


Python Image.png方法代碼示例

本文整理匯總了Python中jicbioimage.core.image.Image.png方法的典型用法代碼示例。如果您正苦於以下問題:Python Image.png方法的具體用法?Python Image.png怎麽用?Python Image.png使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在jicbioimage.core.image.Image的用法示例。


在下文中一共展示了Image.png方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_repr_html

# 需要導入模塊: from jicbioimage.core.image import Image [as 別名]
# 或者: from jicbioimage.core.image.Image import png [as 別名]
    def test_repr_html(self):
        from jicbioimage.core.image import MicroscopyCollection, MicroscopyImage, Image
        microscopy_collection = MicroscopyCollection()
        image = Image((50,50))
        image.png = MagicMock(return_value=bytearray('image', encoding='utf-8'))
        with patch('jicbioimage.core.image.Image.from_file', return_value=image) as patched_image:
            microscopy_collection.append(MicroscopyImage('test0.tif',
                dict(series=1, channel=2, zslice=3, timepoint=4)))
            html = microscopy_collection._repr_html_()
            self.assertEqual(html.strip().replace(' ', '').replace('\n', ''),
'''
<div style="float: left; padding: 2px;" >
    <p>
        <table>
            <tr>
                <th>Index</th>
                <th>Series</th>
                <th>Channel</th>
                <th>Z-slice</th>
                <th>Time point</th>
            </tr>
            <tr>
                <td>0</td>
                <td>1</td>
                <td>2</td>
                <td>3</td>
                <td>4</td>
            </tr>
        </table>
    </p>
    <img style="margin-left: auto; margin-right: auto;" src="data:image/png;base64,aW1hZ2U=" />
</div>
'''.strip().replace(' ', '').replace('\n', ''))
開發者ID:JIC-CSB,項目名稱:jicbioimage.core,代碼行數:35,代碼來源:MicroscopyCollection_unit_tests.py

示例2: test_png_with_width

# 需要導入模塊: from jicbioimage.core.image import Image [as 別名]
# 或者: from jicbioimage.core.image.Image import png [as 別名]
    def test_png_with_width(self):
        from jicbioimage.core.image import Image
        image = Image((600, 800), dtype=np.uint64)
        thumbnail = image.png(width=300)

        ar = np.asarray(PIL.Image.open(io.BytesIO(thumbnail)))

        self.assertEqual(ar.shape[0], 300)
        self.assertEqual(ar.shape[1], 400)
開發者ID:JIC-CSB,項目名稱:jicbioimage.core,代碼行數:11,代碼來源:Image_unit_tests.py

示例3: test_png

# 需要導入模塊: from jicbioimage.core.image import Image [as 別名]
# 或者: from jicbioimage.core.image.Image import png [as 別名]
    def test_png(self):
        from jicbioimage.core.image import Image
        image = Image((600, 500), dtype=np.uint64)
        png = image.png()

        ar = np.asarray(PIL.Image.open(io.BytesIO(png)))

        self.assertEqual(ar.shape[0], 600)
        self.assertEqual(ar.shape[1], 500)
開發者ID:JIC-CSB,項目名稱:jicbioimage.core,代碼行數:11,代碼來源:Image_unit_tests.py

示例4: test_repr_html

# 需要導入模塊: from jicbioimage.core.image import Image [as 別名]
# 或者: from jicbioimage.core.image.Image import png [as 別名]
    def test_repr_html(self):
        from jicbioimage.core.image import ImageCollection, ProxyImage, Image
        image_collection = ImageCollection()
        image = Image((50,50))
        image.png = MagicMock(return_value=bytearray('image', encoding='utf-8'))
        with patch('jicbioimage.core.image.Image.from_file', return_value=image) as patched_image:
            image_collection.append(ProxyImage('test0.tif'))
            html = image_collection._repr_html_()
            self.assertEqual(html.strip().replace(' ', '').replace('\n', ''),
'''
<div style="float: left; padding: 2px;" >
    <p>
        <table><tr><th>Index</th><td>0</td></tr></table>
    </p>
    <img style="margin-left: auto; margin-right: auto;" src="data:image/png;base64,aW1hZ2U=" />
</div>
'''.strip().replace(' ', '').replace('\n', ''))

        image.png.assert_called_once_with(width=300)
開發者ID:JIC-CSB,項目名稱:jicbioimage.core,代碼行數:21,代碼來源:ImageCollection_unit_tests.py


注:本文中的jicbioimage.core.image.Image.png方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。