Skip to content

Commit

Permalink
MIN convert argument to np.uint8 in overlay()
Browse files Browse the repository at this point in the history
The function is to be used to visualize results, so this is often the
desired result. The code already implicitly assumed np.uint8 as it used
255 as the highest value.

close #62
  • Loading branch information
luispedro committed Jul 25, 2015
1 parent 3c519c0 commit 357bf1b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mahotas/mahotas_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.4.0'
__version__ = '1.4.0+git'
16 changes: 13 additions & 3 deletions mahotas/stretch.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,24 +176,34 @@ def s(c):
return np.dstack([s(r), s(g), s(b)])


def overlay(gray, red=None, green=None, blue=None):
def overlay(gray, red=None, green=None, blue=None, if_gray_dtype_not_uint8='stretch'):
'''
Create an image which is greyscale, but with possible boolean overlays.
Parameters
----------
gray: ndarray
Should be a greyscale image
gray: ndarray of type np.uint8
Should be a greyscale image of type np.uint8
red,green,blue : ndarray, optional
boolean arrays
if_gray_dtype_not_uint8 : str, optional
What to do if ``gray`` is not of type ``np.uint8``, must be one of
'stretch' (default): the function ``stretch`` is called.
'error' : in this case, an error is raised
Returns
-------
overlaid : ndarray
Colour image
'''
_check_2(gray, 'overlay')
if gray.dtype != np.uint8:
if if_gray_dtype_not_uint8 == 'stretch':
gray = stretch(gray)
else:
raise ValueError('mahotas.overlay: first argument should be of dtype np.uint8')
def _v(ch):
if ch is None:
return gray
Expand Down

0 comments on commit 357bf1b

Please sign in to comment.