Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to invert black and white with scikit-image?

I read an image with ndimage, which results in a binary image like this:

enter image description here

I would like to invert the image such that white turns into black, and vice versa.

Help is appreciated.

like image 991
Pamungkas Jayuda Avatar asked Jan 22 '15 09:01

Pamungkas Jayuda


People also ask

How do I reverse an image in OpenCV Python?

To invert a mask in OpenCV, we use the cv2. bitwise_not() function, which performs bitwise not operation on individual pixels. Parameters: masked_image: It is the image that is to be inverted.

How do I invert colors in NumPy?

In order to invert the image, we have to apply the broadcasting technique using NumPy. We have to subtract each pixel value from 255. It is because the highest pixel value or color value is 255 in an image. Either way, we can apply the '~' (negation) operation to the image.

How do you invert a binary image?

If you have a binary image binImage with just zeroes and ones, there are a number of simple ways to invert it: binImage = ~binImage; binImage = 1-binImage; binImage = (binImage == 0); Then just save the inverted image using the function IMWRITE.


1 Answers

numpy.invert(close_img)

I use invert array. It works for me.

like image 115
Pamungkas Jayuda Avatar answered Oct 02 '22 17:10

Pamungkas Jayuda