"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "skimage/io/_plugins/pil_plugin.py" between
scikit-image-0.19.2.tar.gz and scikit-image-0.19.3.tar.gz

About: scikit-image is a collection of algorithms for image processing in Python.

pil_plugin.py  (scikit-image-0.19.2):pil_plugin.py  (scikit-image-0.19.3)
skipping to change at line 153 skipping to change at line 153
PIL Image that is in Palette mode. PIL Image that is in Palette mode.
Returns Returns
------- -------
is_grayscale : bool is_grayscale : bool
True if all colors in image palette are gray. True if all colors in image palette are gray.
""" """
if pil_image.mode != 'P': if pil_image.mode != 'P':
raise ValueError('pil_image.mode must be equal to "P".') raise ValueError('pil_image.mode must be equal to "P".')
# get palette as an array with R, G, B columns # get palette as an array with R, G, B columns
palette = np.asarray(pil_image.getpalette()).reshape((256, 3)) palette = np.asarray(pil_image.getpalette()).reshape((-1, 3))
# Not all palette colors are used; unused colors have junk values. # Not all palette colors are used; unused colors have junk values.
start, stop = pil_image.getextrema() start, stop = pil_image.getextrema()
valid_palette = palette[start:stop + 1] valid_palette = palette[start:stop + 1]
# Image is grayscale if channel differences (R - G and G - B) # Image is grayscale if channel differences (R - G and G - B)
# are all zero. # are all zero.
return np.allclose(np.diff(valid_palette), 0) return np.allclose(np.diff(valid_palette), 0)
def ndarray_to_pil(arr, format_str=None): def ndarray_to_pil(arr, format_str=None):
"""Export an ndarray to a PIL object. """Export an ndarray to a PIL object.
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)