python手记(37)

#!/usr/bin/env python
#-*- coding: utf-8 -*-
#code:myhaspl@qq.com
import cv2
import numpy as np


fn="test1.jpg"
if __name__ == '__main__':
    print 'http://blog.csdn.net/myhaspl'
    print 'myhaspl@qq.com'
    print
    print 'loading %s ...' % fn
    print 'working',
    img = cv2.imread(fn)
    w=img.shape[1]
    h=img.shape[0]
    sz1=w/2
    sz0=h/2
    #创建空白图像
    myimg1=np.zeros((sz0,sz1,3), np.uint8)      
    #缩小图像,每2个像素取1个
    for now_y in xrange(0,sz0):
        for now_x in xrange(0,sz1):
            myimg1[now_y,now_x,:]=img[now_y*2,now_x*2,:]           
              
        print '.',
    cv2.namedWindow('img1')     
    cv2.imshow('img1', myimg1)    
    cv2.waitKey()
    cv2.destroyAllWindows()

python opencv 缩小图像


>>> runfile(r'K:\testpro\testopencv.py', wdir=r'K:\testpro')
http://blog.csdn.net/myhaspl
myhaspl@qq.com


loading test1.jpg ...
working . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
>>> 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值