How to invert black and white with scikit-image?

With the devel version of scikit-image (upcomming v0.13), you can use invert(). Example:

from skimage import util 
img = data.camera() 
inverted_img = util.invert(img)

Here's another method using OpenCV

import cv2

image = cv2.imread('2.png')
invert = cv2.bitwise_not(image) # OR
# invert = 255 - image


numpy.invert(close_img)

I use invert array. It works for me.


If your image is represented with non-negative floating point values topping out at 1.0, you can use 1 - close_image