Files
scikit-image/skimage/novice/__init__.py
T
Tony S Yu 1a418f8820 Clean up novice __init__
Move functions from __init__ to novice module and clean up package docstring.
Doctest now passes.
2013-10-21 23:02:45 -05:00

74 lines
1.7 KiB
Python

"""
skimage.novice
==============
A special Python image submodule for beginners.
Description
-----------
``skimage.novice`` provides a simple image manipulation interface for
beginners. It allows for easy loading, manipulating, and saving of image
files.
This module is primarily intended for teaching and differs significantly from
the normal, array-oriented image functions used by scikit-image.
.. note::
This module uses the Cartesian coordinate system, where the origin is at
the lower-left corner instead of the upper-right.
Example
-------
We can create a Picture object open opening an image file
>>> from skimage import novice
>>> from skimage import data
>>> picture = novice.open(data.data_dir + '/elephant.png')
Pictures know their format
>>> print picture.format
png
... and where they came from
>>> print picture.path.endswith('elephant.png')
True
... and their size
>>> print picture.size
(665, 500)
>>> print picture.width
665
Changing `size` resizes the picture.
>>> picture.size = (200, 250)
You can iterate over pixels, which have RGB values between 0 and 255,
and know their location in the picture.
>>> for pixel in picture:
... if (pixel.red > 128) and (pixel.x < picture.width):
... pixel.red /= 2
Pictures know if they've been modified from the original file
>>> print picture.modified
True
>>> print picture.path
None
Pictures can be indexed like arrays
>>> picture[0:20, 0:20] = (0, 0, 0)
Saving the picture updates the path attribute, format, and modified state.
>>> picture.save('sample-bluegreen.jpg')
>>> print picture.path.endswith('sample-bluegreen.jpg')
True
>>> print picture.format
jpeg
>>> print picture.modified
False
"""
from . import colors
from .novice import Picture, open, new, copy