Mercurial > repos > imgteam > projective_transformation
comparison projective_transformation.py @ 7:6a8ae8cd7167 draft default tip
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/projective_transformation/ commit c86a1b93cb7732f7331a981d13465653cc1a2790
author | imgteam |
---|---|
date | Wed, 24 Apr 2024 08:13:05 +0000 |
parents | 37b079c98c38 |
children |
comparison
equal
deleted
inserted
replaced
6:2f504e075496 | 7:6a8ae8cd7167 |
---|---|
7 """ | 7 """ |
8 | 8 |
9 import argparse | 9 import argparse |
10 import warnings | 10 import warnings |
11 | 11 |
12 import giatools.io | |
12 import numpy as np | 13 import numpy as np |
13 import pandas as pd | 14 import pandas as pd |
14 import skimage.color | 15 import skimage.color |
15 import skimage.io | 16 import skimage.io |
16 import tifffile | 17 import tifffile |
45 | 46 |
46 return coords | 47 return coords |
47 | 48 |
48 | 49 |
49 def transform(moving_fn, fixed_fn, warp_mat, output_fn): | 50 def transform(moving_fn, fixed_fn, warp_mat, output_fn): |
50 moving = skimage.io.imread(moving_fn) | 51 moving = giatools.io.imread(moving_fn) |
51 nDims = len(moving.shape) | 52 nDims = len(moving.shape) |
52 assert nDims in [2, 3, 4, 5, 6], 'this tool only supports up to 6 dimensions' | 53 assert nDims in [2, 3, 4, 5, 6], 'this tool only supports up to 6 dimensions' |
53 | 54 |
54 if moving.shape[-1] in [3, 4] and nDims > 2: | 55 if moving.shape[-1] in [3, 4] and nDims > 2: |
55 isRGB = True | 56 isRGB = True |
60 if nDims > 3 or (nDims == 3 and not isRGB): | 61 if nDims > 3 or (nDims == 3 and not isRGB): |
61 isMulCh = True | 62 isMulCh = True |
62 else: | 63 else: |
63 isMulCh = False | 64 isMulCh = False |
64 | 65 |
65 fixed = skimage.io.imread(fixed_fn) | 66 fixed = giatools.io.imread(fixed_fn) |
66 if fixed.shape[-1] in [3, 4] and len(fixed.shape) > 2: | 67 if fixed.shape[-1] in [3, 4] and len(fixed.shape) > 2: |
67 hw_fixed = fixed.shape[-3:-1] | 68 hw_fixed = fixed.shape[-3:-1] |
68 else: | 69 else: |
69 hw_fixed = fixed.shape[-2:] | 70 hw_fixed = fixed.shape[-2:] |
70 | 71 |