在skimage中裁剪图像? [英] crop image in skimage?

查看:268
本文介绍了在skimage中裁剪图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用skimage裁剪给定图像中的矩形,现在我将(x1,y1,x2,y2)作为矩形坐标,然后加载了图像

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.imread(filename)
 cropped = image(x1,y1,x2,y2)

但这是裁剪图像的错误方法,我将如何在skimage中以正确的方式进行处理

However this is the wrong way to crop the image, how would I do it in the right way in skimage

推荐答案

这似乎是一个简单的语法错误.

This seems a simple syntax error.

好吧,在Matlab中,您可以使用_'parentheses'_提取像素或图像区域.但是在Python和numpy.ndarray中,应该使用方括号将图像的区域切成薄片,除了在此代码中,您还使用了错误的方式来切割矩形.

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.

因此

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

这篇关于在skimage中裁剪图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆