Skip to content

Commit b06ca30

Browse files
committed
Replace ImageMagick-based gamma correction with a own version, update documentation
1 parent eedba29 commit b06ca30

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

bin/halostack_cli.py

+2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ def halostack_cli(args):
101101
if not args['no_alignment'] and len(images) > 0:
102102
view_img = base_img.luminance()
103103
if isinstance(args['view_gamma'], float):
104+
from halostack.image import _scale
104105
view_img.enhance({'gamma': args['view_gamma']})
106+
view_img.img = _scale(view_img.img, bits=8)
105107
print "\nClick tight area (two opposite corners) for "\
106108
"reference location.\n"
107109
args['focus_reference'] = get_two_points(view_img)

doc/source/usage.rst

+17-2
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,13 @@ Below is an example configuration::
235235
# average stack from raw/tiff images with view gamma set
236236
[avg_from_raw]
237237
avg_stack_file = average.png
238-
view_gamma = 1.5
238+
view_gamma = 0.45
239239

240240
# average stack from linear raw/tiff images with view gamma set
241241
# and USM applied to the stack
242242
[avg_from_raw]
243243
avg_stack_file = average.png
244-
view_gamma = 1.5
244+
view_gamma = 0.45
245245
enhance_stacks = usm:25,2
246246

247247
# B-R processing without stacking
@@ -496,4 +496,19 @@ is equal to::
496496
-E stretch:0.02,0.98
497497

498498

499+
Gamma correction
500+
++++++++++++++++
501+
502+
Apply gamma correction to the image. Can be used in either of pre- or
503+
post-processing.
504+
505+
Syntax::
506+
507+
- E gamma:0.5
508+
- E gamma:2.0
509+
510+
Values less than one makes the image lighter and greather value
511+
darkens the image.
512+
513+
499514
.. _Lefadeux: http://opticsaround.blogspot.fr/2013/03/le-traitement-bleu-moins-rouge-blue.html

halostack/image.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def enhance(self, enhancements):
289289
* ``float``: light source azimuth in degrees [``90``]
290290
* ``float``: light source elevation in degrees [``45``]
291291
292-
* ``gamma``: gamma correction using *ImageMagick*
292+
* ``gamma``: gamma correction
293293
294294
* possible calls:
295295
@@ -752,10 +752,10 @@ def _gamma(self, args):
752752
return
753753
if not isinstance(args, list):
754754
args = [args]
755-
self._to_imagemagick()
755+
self._to_numpy()
756756
LOGGER.debug("Apply gamma correction, gamma: %.2lf.", args[0])
757-
self.img.gamma(args[0])
758-
757+
self.img /= self.img.max()
758+
self.img **= args[0]
759759

760760
def _blur_worker(data_in):
761761
'''Worker for blurring rows in parallel.

0 commit comments

Comments
 (0)