| 12 | self.title = name.split('.')[0].replace('\\', '/').split('/')[-1] |
| 13 | |
| 14 | def run(self, para = None): |
| 15 | root_dir = osp.abspath(osp.dirname(self.path)) |
| 16 | print(root_dir) |
| 17 | path = osp.join(root_dir, self.name) |
| 18 | if osp.isfile(path): |
| 19 | fp, fn = osp.split(path) |
| 20 | fn, fe = osp.splitext(fn) |
| 21 | read = ReaderManager.get(fe[1:]) |
| 22 | view = ViewerManager.get(fe[1:]) |
| 23 | |
| 24 | group, read = (True, read[0]) if isinstance(read, tuple) else (False, read) |
| 25 | img = read(path) |
| 26 | if img.dtype==np.uint8 and img.ndim==3 and img.shape[2]==4: |
| 27 | img = img[:,:,:3].copy() |
| 28 | if not group: img = [img] |
| 29 | else: |
| 30 | names = [i for i in os.listdir(path) if '.' in i] |
| 31 | read = ReaderManager.get(names[0].split('.')[1]) |
| 32 | view = ViewerManager.get(names[0].split('.')[1]) |
| 33 | imgs = [] |
| 34 | for i in range(len(names)): |
| 35 | self.progress(i, len(names)) |
| 36 | imgs.append(read(osp.join(path,names[i]))) |
| 37 | img = imgs |
| 38 | view(img, self.title) |
| 39 | |
| 40 | def __call__(self): |
| 41 | return self |