如何减少图像处理中的图像大小(scipy / numpy / python) [英] How to reduce an image size in image processing (scipy/numpy/python)

查看:126
本文介绍了如何减少图像处理中的图像大小(scipy / numpy / python)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我有一个图像(1024 x 1024),我在numpy中使用fromfile命令将该图像的每个像素放入一个矩阵。

Hello I have an image ( 1024 x 1024) and I used "fromfile" command in numpy to put every pixel of that image into a matrix.

怎么能我通过修改矩阵来减小图像的大小(例如512 x 512)?

How can I reduce the size of the image ( ex. to 512 x 512) by modify that matrix a?

a = numpy.fromfile(( - path - ,'uint8').reshape((1024,1024))

我有不知道如何修改矩阵a以减小图像的大小。所以,如果有人有任何想法,请分享您的知识,我将不胜感激。谢谢

I have no idea how to modify the matrix a to reduce the size of the image. So if somebody has any idea, please share your knowledge and I will be appreciated. Thanks

编辑:

当我看到结果时,我发现读者已经阅读了图像并将其放入矩阵。所以我将数组更改为矩阵。

When I look at the result, I found that the reader I got read the image and put it into a "matrix". So I changed the "array" to matrix.

何塞告诉我,我只能采用偶数列甚至行并将其放入一个新矩阵。将图像缩小到一半。我需要使用scipy / numpy中的哪个命令来执行此操作?

Jose told me I can take only even column and even row and put it into a new matrix . That will reduce the image to half size. What command in scipy/numpy do I need to use to do that?

谢谢

推荐答案

我是nk最简单的方法是只取一些列和一些图像行。制作一个数组样本。例如,只有那些偶数行和偶数列,将它放在一个新的数组中,你将有一个半尺寸的新图像。

I think the easyiest way is to take only some columns and some rows of the image. Makeing a sample of the array. Take for example, only those even rows and the even columns, put it in a new array and you would have a half size new image.

这篇关于如何减少图像处理中的图像大小(scipy / numpy / python)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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