本文整理汇总了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', ''))
示例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)
示例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)
示例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)