Skip to content

Instantly share code, notes, and snippets.

@ntjess
Last active December 3, 2020 21:28
Show Gist options
  • Save ntjess/763f301b28e7e700e0af585b84ab8d5a to your computer and use it in GitHub Desktop.
Save ntjess/763f301b28e7e700e0af585b84ab8d5a to your computer and use it in GitHub Desktop.
Image Exporter plugin
from s3a.parameditors import ParamEditorPlugin, ParamEditor, FR_SINGLETON
from skimage import io
class InfoExporterPlugin(ParamEditorPlugin):
name = 'Info Exporter'
@classmethod
def __initEditorParams__(cls):
super().__initEditorParams__()
cls.toolsEditor = ParamEditor.buildClsToolsEditor(cls, 'Tools')
cls.dock.addEditors([cls.toolsEditor])
def __init__(self):
super().__init__()
self.toolsEditor.registerFunc(self.exportStageImages)
def exportStageImages(self, outFolder='.'):
"""
:param outFolder:
pType: filepicker
asFolder: True
"""
outFolder = Path(outFolder)
outFolder.mkdir(exist_ok=True)
plugin = self.s3a.focusedImg.currentPlugin
for info in plugin.curProcessor.processor.getStageInfos():
img = info['image']
io.imsave(outFolder/f'{info["name"]}.jpg', img)
s3a.addPlugin(InfoExporterPlugin)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment