【腾讯云】亏本大甩卖，服务器4核16G 1年370元(带宽12M,系统盘120GB SSD盘,月流量2000GB)!!!!!!

MySQL 1核1G 19元/年

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.

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))
``````

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

EDIT:

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.

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?

Thanks

#### #0

If you want to resize to specific resolution, use scipy.misc.imresize:

``````import scipy.misc

i_width = 640
i_height = 480

scipy.misc.imresize(original_image, (i_height, i_width))
``````

#### #1

Use the zoom function from scipy:

http://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.zoom.html#scipy.ndimage.zoom

``````from scipy.ndimage.interpolation import zoom
a = np.ones((1024, 1024))
small_a = zoom(a, 0.5)
``````

#### #2

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.

#### 阅读全文

Firefox表格css generate tbody killing table width

Java标准版中有多少类？

Visual Studio Ultimate 2010：检查win7 SDK？