How to invert black and white with scikit-image?

后端 未结 5 1162
梦毁少年i
梦毁少年i 2021-01-01 23:30

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

\"enter

相关标签:
5条回答
  • 2021-01-01 23:49

    Here's another method using OpenCV

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

    0 讨论(0)
  • 2021-01-01 23:53

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

    0 讨论(0)
  • 2021-01-01 23:59

    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)
    
    0 讨论(0)
  • 2021-01-02 00:01
    numpy.invert(close_img)
    

    I use invert array. It works for me.

    0 讨论(0)
  • 2021-01-02 00:07

    I like Pamungkas Jayuda's anwer, but it works only on the assumption that your data is an integer. In my case, I just used simple inversion with a small value on the denominator to avoid division by zero:

    1 / (2e5 + img)
    
    0 讨论(0)
提交回复
热议问题