File tree Expand file tree Collapse file tree 3 files changed +80
-1
lines changed
Expand file tree Collapse file tree 3 files changed +80
-1
lines changed Original file line number Diff line number Diff line change 55
66"""
77DataLab
8- ============
8+ =======
99
1010DataLab is a generic signal and image processing software based on Python
1111scientific libraries (such as NumPy, SciPy or scikit-image) and Qt graphical
Original file line number Diff line number Diff line change 1+ # -*- coding: utf-8 -*-
2+
3+ """
4+ Empty plugin example
5+ ====================
6+
7+ This is an empty example of a DataLab plugin.
8+
9+ It adds a new menu entry in "Plugins" menu, with a sub-menu "Empty plugin (example)".
10+ This sub-menu contains one action, "Do nothing".
11+ """
12+
13+ import cdl .plugins
14+
15+
16+ class EmptyPlugin (cdl .plugins .PluginBase ):
17+ """DataLab Example Plugin"""
18+
19+ PLUGIN_INFO = cdl .plugins .PluginInfo (
20+ name = "Empty plugin (example)" ,
21+ version = "1.0.0" ,
22+ description = "This is an empty example plugin" ,
23+ )
24+
25+ def do_nothing (self ) -> None :
26+ """Do nothing"""
27+ self .show_info ("Do nothing" )
28+
29+ def create_actions (self ) -> None :
30+ """Create actions"""
31+ acth = self .imagepanel .acthandler
32+ with acth .new_menu (self .PLUGIN_INFO .name ):
33+ # Note: in the following call, `select_condition` is by default `None`,
34+ # so the action is enabled only if at least one image is selected.
35+ acth .new_action ("Do nothing" , triggered = self .do_nothing )
Original file line number Diff line number Diff line change 1+ # -*- coding: utf-8 -*-
2+
3+ """
4+ Image format Plugin for DataLab (example)
5+ =========================================
6+
7+ This plugin is an example of how to add a new image file format to DataLab.
8+
9+ It provides a new image file format, Dürr NDT XYZ, from Dürr NDT GmbH & Co. KG
10+ (see `Dürr NDT website <https://www.duerr-ndt.com/>`_).
11+ """
12+
13+ import numpy as np
14+
15+ from cdl .core .io .base import FormatInfo
16+ from cdl .core .io .image .base import ImageFormatBase
17+
18+
19+ class XYZImageFormat (ImageFormatBase ):
20+ """Object representing Dürr NDT XYZ image file type"""
21+
22+ FORMAT_INFO = FormatInfo (
23+ name = "Dürr NDT" ,
24+ extensions = "*.xyz" ,
25+ readable = True ,
26+ writeable = False ,
27+ )
28+
29+ @staticmethod
30+ def read_data (filename : str ) -> np .ndarray :
31+ """Read data and return it
32+
33+ Args:
34+ filename (str): path to XYZ file
35+
36+ Returns:
37+ np.ndarray: image data
38+ """
39+ with open (filename , "rb" ) as fdesc :
40+ cols = int (np .fromfile (fdesc , dtype = np .uint16 , count = 1 )[0 ])
41+ rows = int (np .fromfile (fdesc , dtype = np .uint16 , count = 1 )[0 ])
42+ arr = np .fromfile (fdesc , dtype = np .uint16 , count = cols * rows )
43+ arr = arr .reshape ((rows , cols ))
44+ return np .fliplr (arr )
You can’t perform that action at this time.
0 commit comments