<s> import matplotlib . pyplot as plt <EOL> from skimage import data <EOL> from skimage import filters <EOL> from skimage import morphology <EOL> from skimage . viewer import ImageViewer <EOL> from skimage . viewer . widgets import history <EOL> from skimage . viewer . plugins . labelplugin import LabelPainter <EOL> class OKCancelButtons ( history . OKCancelButtons ) : <EOL> def update_original_image ( self ) : <EOL> self . plugin . _show_watershed ( ) <EOL> self . plugin . close ( ) <EOL> class WatershedPlugin ( LabelPainter ) : <EOL> def help ( self ) : <EOL> helpstr = ( "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> return '<STR_LIT:\n>' . join ( helpstr ) <EOL> def _show_watershed ( self ) : <EOL> viewer = self . image_viewer <EOL> edge_image = filter . sobel ( viewer . image ) <EOL> labels = morphology . watershed ( edge_image , self . paint_tool . overlay ) <EOL> viewer . ax . imshow ( labels , cmap = plt . cm . jet , alpha = <NUM_LIT:0.5> ) <EOL> viewer . redraw ( ) <EOL> image = data . coins ( ) <EOL> plugin = WatershedPlugin ( ) <EOL> plugin += OKCancelButtons ( ) <EOL> viewer = ImageViewer ( image ) <EOL> viewer += plugin <EOL> viewer . show ( ) </s>
