Skip to content

Commit

Permalink
Replace ImageMagick-based gamma correction with a own version, update…
Browse files Browse the repository at this point in the history
… documentation
  • Loading branch information
pnuu committed Mar 5, 2016
1 parent eedba29 commit b06ca30
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
2 changes: 2 additions & 0 deletions bin/halostack_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ def halostack_cli(args):
if not args['no_alignment'] and len(images) > 0:
view_img = base_img.luminance()
if isinstance(args['view_gamma'], float):
from halostack.image import _scale
view_img.enhance({'gamma': args['view_gamma']})
view_img.img = _scale(view_img.img, bits=8)
print "\nClick tight area (two opposite corners) for "\
"reference location.\n"
args['focus_reference'] = get_two_points(view_img)
Expand Down
19 changes: 17 additions & 2 deletions doc/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,13 @@ Below is an example configuration::
# average stack from raw/tiff images with view gamma set
[avg_from_raw]
avg_stack_file = average.png
view_gamma = 1.5
view_gamma = 0.45

# average stack from linear raw/tiff images with view gamma set
# and USM applied to the stack
[avg_from_raw]
avg_stack_file = average.png
view_gamma = 1.5
view_gamma = 0.45
enhance_stacks = usm:25,2

# B-R processing without stacking
Expand Down Expand Up @@ -496,4 +496,19 @@ is equal to::
-E stretch:0.02,0.98


Gamma correction
++++++++++++++++

Apply gamma correction to the image. Can be used in either of pre- or
post-processing.

Syntax::

- E gamma:0.5
- E gamma:2.0

Values less than one makes the image lighter and greather value
darkens the image.


.. _Lefadeux: http://opticsaround.blogspot.fr/2013/03/le-traitement-bleu-moins-rouge-blue.html
8 changes: 4 additions & 4 deletions halostack/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def enhance(self, enhancements):
* ``float``: light source azimuth in degrees [``90``]
* ``float``: light source elevation in degrees [``45``]
* ``gamma``: gamma correction using *ImageMagick*
* ``gamma``: gamma correction
* possible calls:
Expand Down Expand Up @@ -752,10 +752,10 @@ def _gamma(self, args):
return
if not isinstance(args, list):
args = [args]
self._to_imagemagick()
self._to_numpy()
LOGGER.debug("Apply gamma correction, gamma: %.2lf.", args[0])
self.img.gamma(args[0])

self.img /= self.img.max()
self.img **= args[0]

def _blur_worker(data_in):
'''Worker for blurring rows in parallel.
Expand Down

0 comments on commit b06ca30

Please sign in to comment.