Mercurial > repos > imgteam > 2d_histogram_equalization
view histogram_equalization.py @ 2:3f3783846dc0 draft
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_histogram_equalization/ commit c045f067a57e8308308cf6329060c7ccd3fc372f
author | imgteam |
---|---|
date | Thu, 04 Apr 2024 15:23:34 +0000 |
parents | 77f7159d775a |
children | b1c2c210813c |
line wrap: on
line source
import argparse import sys import skimage.exposure import skimage.io import skimage.util hOptions = { 'default': lambda img_raw: skimage.exposure.equalize_hist(img_raw), 'clahe': lambda img_raw: skimage.exposure.equalize_adapthist(img_raw) } if __name__ == "__main__": parser = argparse.ArgumentParser(description='Histogram equalization') parser.add_argument('input_file', type=argparse.FileType('r'), default=sys.stdin, help='input file') parser.add_argument('out_file', type=argparse.FileType('w'), default=sys.stdin, help='out file (TIFF)') parser.add_argument('h_type', choices=hOptions.keys(), help='histogram equalization method') args = parser.parse_args() img_in = skimage.io.imread(args.input_file.name) res = hOptions[args.h_type](img_in) res = skimage.util.img_as_uint(res) skimage.io.imsave(args.out_file.name, res, plugin="tifffile")