Mercurial > repos > imgteam > points2binaryimage
diff points2binaryimage.py @ 1:90385ec28b34 draft
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/points2binaryimage/ commit 2286a6c9da88596349ed9d967c51541409c0a7bf
author | imgteam |
---|---|
date | Mon, 13 Nov 2023 22:11:42 +0000 |
parents | dd513c9f5230 |
children | 4c0f16fb9f8d |
line wrap: on
line diff
--- a/points2binaryimage.py Sat Feb 09 14:43:25 2019 -0500 +++ b/points2binaryimage.py Mon Nov 13 22:11:42 2023 +0000 @@ -1,11 +1,11 @@ import argparse -import sys -import numpy as np -import skimage.io -import pandas as pd import os import warnings +import numpy as np +import pandas as pd +import skimage.io + def points2binaryimage(point_file, out_file, shape=[500, 500], has_header=False, invert_xy=False): @@ -22,21 +22,22 @@ raise IndexError("Point {},{} is out of image with bounds {},{}.".format(int(a_row[0]), int(a_row[1]), shape[0], shape[1])) if invert_xy: - if img.shape[0]<=int(a_row[0]) or img.shape[1]<=int(a_row[1]): + if img.shape[0] <= int(a_row[0]) or img.shape[1] <= int(a_row[1]): raise IndexError("Point {},{} is out of image with bounds {},{}.".format(int(a_row[0]), int(a_row[1]), shape[0], shape[1])) else: img[int(a_row[1]), int(a_row[0])] = 32767 else: - if img.shape[0]<=int(a_row[1]) or img.shape[1]<=int(a_row[0]): + if img.shape[0] <= int(a_row[1]) or img.shape[1] <= int(a_row[0]): raise IndexError("Point {},{} is out of image with bounds {},{}.".format(int(a_row[1]), int(a_row[0]), shape[0], shape[1])) else: img[int(a_row[0]), int(a_row[1])] = 32767 else: - raise Exception("{} is empty or does not exist.".format(point_file)) # appropriate built-in error? + raise Exception("{} is empty or does not exist.".format(point_file)) # appropriate built-in error? with warnings.catch_warnings(): warnings.simplefilter("ignore") - skimage.io.imsave(out_file, img, plugin='tifffile') # otherwise we get problems with the .dat extension + skimage.io.imsave(out_file, img, plugin='tifffile') # otherwise we get problems with the .dat extension + if __name__ == "__main__": parser = argparse.ArgumentParser() @@ -49,5 +50,5 @@ args = parser.parse_args() - #TOOL + # TOOL points2binaryimage(args.point_file.name, args.out_file, [args.shapey, args.shapex], has_header=args.has_header, invert_xy=args.invert_xy)