python手记(38)

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


loading test.png ...

working . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


 

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


fn="test.png"
if __name__ == '__main__':
    print 'http://blog.youkuaiyun.com/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个像素的值
    temp_x=0
    temp_y=0
    for now_y in xrange(0,sz0):
        temp_x=0
        for now_x in xrange(0,sz1):
            myimg1[now_y,now_x,:]=img[int(temp_y),int(temp_x),:]     
            temp_x+=0.5
            print '.',
        temp_y+=0.5
              

    cv2.namedWindow('img1')     
    cv2.imshow('img1', myimg1)    
    cv2.waitKey()
    cv2.destroyAllWindows()


python  opencv 放大图像

 


 

转载于:https://www.cnblogs.com/james1207/p/3278375.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值