I have problems storing my image after watershed segmentation as a binary image. When I plot the segmentation with cmap=plt.cm.gray it shows a binary image but I don't know how to store the image (without to display it).
import cv2
import numpy as np
from matplotlib import pyplot as plt
from skimage.morphology import watershed
from scipy import ndimage as ndi
from skimage import morphology
from skimage.filters import sobel
from skimage.io import imread, imsave, imshow
import scipy.misc
img = cv2.imread('07.png')
img = cv2.medianBlur(img,5)
b,g,r = cv2.split(img)
elevation_map = sobel(r)
markers = np.zeros_like(r)
markers[s < 140] = 1
markers[s > 200] = 2
segmentation = morphology.watershed(elevation_map, markers)
fig, ax = plt.subplots(figsize=(4, 3))
ax.imshow(segmentation, cmap=plt.cm.gray, interpolation='nearest')
ax.axis('off')
plt.show()