python手记(31)
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import cv2
import numpy as np fn="test2.jpg" if __name__ == '__main__':
print 'http://blog.csdn.net/myhaspl'
print 'myhaspl@qq.com'
print 'loading %s ...' % fn
print '正在处理中',
img = cv2.imread(fn)
w=img.shape[1]
h=img.shape[0]
ii=0
#生成日落效果
#b[:,:] = img[:,:,0]
#g[:,:] = img[:,:,1]
#r[:,:] = img[:,:,2]
for xi in xrange(0,w):
for xj in xrange (0,h):
img[xj,xi,0]= int(img[xj,xi,0]*0.7)
img[xj,xi,1]= int(img[xj,xi,1]*0.7)
if xi%10==0 :print '.',
cv2.namedWindow('img')
cv2.imshow('img', img)
cv2.waitKey()
cv2.destroyAllWindows()
以下是数组存放红、绿、蓝的位置
#b[:,:] = img[:,:,0]
#g[:,:] = img[:,:,1]
#r[:,:] = img[:,:,2]
>>>
http://blog.csdn.net/myhaspl
myhaspl@qq.com
loading test2.jpg ...
正在处理中 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
>>>
原图是:
也可以如下操作
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import cv2
import numpy as np fn="test2.jpg" if __name__ == '__main__':
print 'http://blog.csdn.net/myhaspl'
print 'myhaspl@qq.com'
print 'loading %s ...' % fn
print '正在处理中',
img = cv2.imread(fn)
w=img.shape[1]
h=img.shape[0]
ii=0
#生成日落效果
#取色彩分量
b, g, r = cv2.split(img)
b=b*0.7
g=g*0.7
#直接通过索引改变色彩分量
img[:,:,0]=b
img[:,:,1]=g
cv2.namedWindow('img')
cv2.imshow('img', img)
cv2.waitKey()
cv2.destroyAllWindows()
python手记(31)的更多相关文章
- python基础31[常用模块介绍]
python基础31[常用模块介绍] python除了关键字(keywords)和内置的类型和函数(builtins),更多的功能是通过libraries(即modules)来提供的. 常用的li ...
- Python 练习 31
则表达式是一个特殊的字符序列,它能帮助你方便的检查一个字符串是否与某种模式匹配. Python 自1.5版本起增加了re 模块,它提供 Perl 风格的正则表达式模式. re 模块使 Python 语 ...
- python手记(50)
#!/usr/bin/env python # -*- coding: utf-8 -*- #http://blog.csdn.net/myhaspl #code:myhaspl@qq.com imp ...
- python手记(26)
#!/usr/bin/env python import cv2 import sys fn="test2.jpg" if __name__ == '__main__': prin ...
- python手记(32)
#!/usr/bin/env python #-*- coding: utf-8 -*- import cv2 import numpy as np fn="test2.jpg" ...
- python手记(30)
#!/usr/bin/env python #-*- coding: utf-8 -*- import cv2 import numpy as np fn="test3.png" ...
- python手记(38)
runfile(r'K:\testpro\testopencv.py', wdir=r'K:\testpro') http://blog.csdn.net/myhaspl myhaspl@qq.com ...
- python手记(39)
#!/usr/bin/env python #-*- coding: utf-8 -*- #code:myhaspl@qq.com import cv2 import numpy as np fn=& ...
- python手记(45)
python 声音编辑,减少音量 #!/usr/bin/env python # -*- coding: utf-8 -*- #http://blog.csdn.net/myhaspl #code:m ...
随机推荐
- RedHat7上安装PHP
编译安装PHP 下载PHP# wget http://cn2.php.net/distributions/php-7.0.0.tar.gz 解压缩PHP# tar -zxvf php-7.0.0.ta ...
- RedHat7安装Nginx及第三方模块
编译安装Nginx 先安装编译过程中所需依赖包# yum -y install gcc pcre-devel openssl-devel zlib-devel jemalloc(更好的内存管理)# w ...
- javascript中强制类型转换
javascript开发过程中,强制类型转换一般发生在条件判断和==运算符.其他情况,发生的类型转换(与这两种情况也是基本类似,属于万变不离其宗的范畴),暂不讨论. == 双等运算符 考虑代码: a ...
- MYSQL 基础操作
1.MySQL基础操作 一:MySQL基础操作 1:MySQL表复制 复制表结构 + 复制表数据 create table t3 like t1; --创建一个和t1一样的表,用like(表结构也一样 ...
- 多线程(Thread),其实很简单!
目录: 1:线程简介 2:怎么操作线程 3:Thread的常用方法 4:简单的获奖机 5:应用程序域 线程:是Windows任务调度的最小单位.线程是程序中的一个执行流,每个线 ...
- C#自定义线程池
自定义线程池-c#的简单实现 下面是代码,希望大家提出更好的建议: 1.ThreadManager.cs using System; using System.Threading; using Sys ...
- Lost connection to MySQL server at ‘reading initial communication packet', system error: 0 mysql远程连接问题
在用Navicat for MySQL远程连接mysql的时候,出现了 Lost connection to MySQL server at ‘reading initial communicatio ...
- php 连接mysql数据库并显示数据 实例 转载
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
- CentOS 6.4 64位 安装 apache-tomcat-6.0.43
下载 tomcat: 地址:http://mirrors.hust.edu.cn/apache/tomcat/tomcat-6/v6.0.43/bin/apache-tomcat-6.0.43.tar ...
- PHP获取当前页面完整url地址,包括参数的函数
//php获取当前访问的完整url地址 function get_current_url(){ $current_url='http://'; if(isset($_SERVER['H ...