crop image in skimage?

前端 未结 4 1753
小蘑菇
小蘑菇 2021-02-09 04:30

I\'m using skimage to crop a rectangle in a given image, now I have (x1,y1,x2,y2) as the rectangle coordinates, then I had loaded the image

 image = skimage.io.         


        
4条回答
  •  情歌与酒
    2021-02-09 04:58

    This seems a simple syntax error.

    Well, in Matlab you can use _'parentheses'_ to extract a pixel or an image region. But in Python, and numpy.ndarray you should use the brackets to slice a region of your image, besides in this code you is using the wrong way to cut a rectangle.

    The right way to cut is using the : operator.

    Thus,

    from skimage import io
    image = io.imread(filename)
    cropped = image[x1:x2,y1:y2]
    

提交回复
热议问题