[英]perform Image cropping on Image like data using Python
I have image-like data.我有类似图像的数据。 And I wont to perform Image cropping, squishing and zooming, on one or both axis.
我不会在一个或两个轴上执行图像裁剪、挤压和缩放。 The problem is that the data is not in between 0-255, and normalizing it to 0-255, would mean loosing a lot of the information I want to preserve.
问题是数据不在 0-255 之间,将其规范化为 0-255 将意味着丢失很多我想保留的信息。 So unfortunately I can't use
PIL
or cv2
.所以不幸的是我不能使用
PIL
或cv2
。 Is there a easy way to do it with numpy
or scipy
?有没有一种简单的方法可以用
numpy
或scipy
做到这scipy
?
Thanks for the help谢谢您的帮助
You can crop pictures with simple indexing, like您可以使用简单的索引裁剪图片,例如
picture[100:300, 400:800]
To squish or zoom (is that anything more than resizing?), you can just resize
with skimage
:要挤压或缩放(这不仅仅是调整大小吗?),您可以使用
skimage
resize
:
from skimage import data, color
from skimage.transform import resize
image = color.rgb2gray(data.astronaut())
image_resized = resize(image, (image.shape[0] // 4, image.shape[1] // 4),
anti_aliasing=True)
检查 Image Librart 的 ImageChops 功能
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.