import cv2
import numpy as np img = cv2.imread("G:\\MyLearning\\TensorFlow_deep_learn\\data\\lena.jpg")
img_hsv = cv2.cvtColor(img,cv2.COLOR_BGR2HSV)
turn_green_hsv = img_hsv.copy()
turn_green_hsv[:,:,0] = (turn_green_hsv[:,:,0] - 30 ) % 180
turn_green_img = cv2.cvtColor(turn_green_hsv,cv2.COLOR_HSV2BGR)
cv2.imshow("test",turn_green_img)
cv2.waitKey(0)

import cv2

img = cv2.imread("G:\\MyLearning\\TensorFlow_deep_learn\\data\\lena.jpg")
img_hsv = cv2.cvtColor(img,cv2.COLOR_BGR2HSV)
less_color_hsv = img_hsv.copy()
less_color_hsv[:, :, 1] = less_color_hsv[:, :, 1] * 0.6
turn_green_img = cv2.cvtColor(less_color_hsv, cv2.COLOR_HSV2BGR)
cv2.imshow("test",turn_green_img)
cv2.waitKey(0)

import cv2

img = cv2.imread("G:\\MyLearning\\TensorFlow_deep_learn\\data\\lena.jpg")
img_hsv = cv2.cvtColor(img,cv2.COLOR_BGR2HSV)
less_color_hsv = img_hsv.copy()
less_color_hsv[:, :, 2] = less_color_hsv[:, :, 2] * 0.6
turn_green_img = cv2.cvtColor(less_color_hsv, cv2.COLOR_HSV2BGR)
cv2.imshow("test",turn_green_img)
cv2.waitKey(0)

import cv2
import numpy as np
import matplotlib.pyplot as plt img = plt.imread("G:\\MyLearning\\TensorFlow_deep_learn\\data\\lena.jpg")
gamma_change = [np.power(x/255,0.4) * 255 for x in range(256)]
gamma_img = np.round(np.array(gamma_change)).astype(np.uint8)
img_corrected = cv2.LUT(img, gamma_img)
plt.subplot(121)
plt.imshow(img)
plt.subplot(122)
plt.imshow(img_corrected)
plt.show()

import cv2
import numpy as np img = cv2.imread("G:\\MyLearning\\TensorFlow_deep_learn\\data\\lena.jpg")
M_copy_img = np.array([[0, 0.8, -200],[0.8, 0, -100]], dtype=np.float32)
img_change = cv2.warpAffine(img, M_copy_img,(300,300))
cv2.imshow("test",img_change)
cv2.waitKey(0)

import cv2
import random img = cv2.imread("G:\\MyLearning\\TensorFlow_deep_learn\\data\\lena.jpg")
width,height,depth = img.shape
img_width_box = width * 0.2
img_height_box = height * 0.2
for _ in range(9):
start_pointX = random.uniform(0, img_width_box)
start_pointY = random.uniform(0, img_height_box)
copyImg = img[int(start_pointX):200, int(start_pointY):200]
cv2.imshow("test", copyImg)
cv2.waitKey(0)
import cv2

img = cv2.imread("G:\\MyLearning\\TensorFlow_deep_learn\\data\\lena.jpg")
rows,cols,depth = img.shape
img_change = cv2.getRotationMatrix2D((cols/2,rows/2),45,1)
res = cv2.warpAffine(img,img_change,(rows,cols))
cv2.imshow("test",res)
cv2.waitKey(0)

import cv2
import numpy as np img = cv2.imread("G:\\MyLearning\\TensorFlow_deep_learn\\data\\lena.jpg")
img_hsv = cv2.cvtColor(img,cv2.COLOR_BGR2HSV)
turn_green_hsv = img_hsv.copy()
turn_green_hsv[:,:,0] = (turn_green_hsv[:,:,0] + np.random.random() ) % 180
turn_green_hsv[:,:,1] = (turn_green_hsv[:,:,1] + np.random.random() ) % 180
turn_green_hsv[:,:,2] = (turn_green_hsv[:,:,2] + np.random.random() ) % 180
turn_green_img = cv2.cvtColor(turn_green_hsv,cv2.COLOR_HSV2BGR)
cv2.imshow("test",turn_green_img)
cv2.waitKey(0)

import cv2

def on_mouse(event, x, y, flags, param):
rect_start = (0,0)
rect_end = (0,0)
if event == cv2.EVENT_LBUTTONDOWN:
rect_start = (x,y)
if event == cv2.EVENT_LBUTTONUP:
rect_end = (x, y)
cv2.rectangle(img, rect_start, rect_end,(0,255,0), 2) img = cv2.imread("G:\\MyLearning\\TensorFlow_deep_learn\\data\\lena.jpg")
cv2.namedWindow('test')
cv2.setMouseCallback("test",on_mouse)
while(1):
cv2.imshow("test",img)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cv2.destroyAllWindows()

吴裕雄 python深度学习与实践(8)的更多相关文章

  1. 吴裕雄 python深度学习与实践(18)

    # coding: utf-8 import time import numpy as np import tensorflow as tf import _pickle as pickle impo ...

  2. 吴裕雄 python深度学习与实践(17)

    import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data import time # 声明输 ...

  3. 吴裕雄 python深度学习与实践(16)

    import struct import numpy as np import matplotlib.pyplot as plt dateMat = np.ones((7,7)) kernel = n ...

  4. 吴裕雄 python深度学习与实践(15)

    import tensorflow as tf import tensorflow.examples.tutorials.mnist.input_data as input_data mnist = ...

  5. 吴裕雄 python深度学习与实践(14)

    import numpy as np import tensorflow as tf import matplotlib.pyplot as plt threshold = 1.0e-2 x1_dat ...

  6. 吴裕雄 python深度学习与实践(13)

    import numpy as np import matplotlib.pyplot as plt x_data = np.random.randn(10) print(x_data) y_data ...

  7. 吴裕雄 python深度学习与实践(12)

    import tensorflow as tf q = tf.FIFOQueue(,"float32") counter = tf.Variable(0.0) add_op = t ...

  8. 吴裕雄 python深度学习与实践(11)

    import numpy as np from matplotlib import pyplot as plt A = np.array([[5],[4]]) C = np.array([[4],[6 ...

  9. 吴裕雄 python深度学习与实践(10)

    import tensorflow as tf input1 = tf.constant(1) print(input1) input2 = tf.Variable(2,tf.int32) print ...

  10. 吴裕雄 python深度学习与实践(9)

    import numpy as np import tensorflow as tf inputX = np.random.rand(100) inputY = np.multiply(3,input ...

随机推荐

  1. 【webdriver自动化】Python数据驱动工具DDT

    一.Python数据驱动工具ddt 1.  安装 ddt pip install ddt DDT是 “Data-Driven Tests”的缩写 资料:http://ddt.readthedocs.i ...

  2. python中序列化模块json和pickle

    json模块:json是第三方包,不是系统内置模块,以字符串序列 常用操作有: json.dumps() # 将变量序列化,即将功能性字符转化为字符串 例: >>> import j ...

  3. javascript继承的6种方法

    1原型式继承 简介:对类式继承的封装,过渡对象相当于子类. function inheritObject(o) { //声明过渡函数对象 function F() {} //过渡对象的原型继承父类 F ...

  4. ViewpageMaiActity

    <?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android=&qu ...

  5. hsdfz -- 6.17 -- day2

    今日依旧康复…… 当天晚上被老师拉去小吃街了,晚上回来精力憔悴,所以并没有当天写 反正就惨,因为估错复杂度,期望得分100分最后结果20分 (我的复杂度是nlog^2n的,正确性有保障,稳! 事后:还 ...

  6. PythonStudy——函数默认值

    # 如果函数的默认参数的默认值为变量,在所属函数定义阶段一执行就被确定为当时变量存放的值 a = 100 def fn(num=a): a = 200 fn() 输出: 100 也就是说在函数调用的时 ...

  7. PythonStudy——字典的定义 Dictionary definition

    # 空字典 d1 = {} d2 = dict() # 用map映射创建字典 d3 = dict({'a': 1, 'b': 1}) print(d3) # 用关键字赋值方式 d4 = dict(na ...

  8. Java注解总结2

    注解是Java元数据,可以理解成代码的标签,正确使用能极大的简化代码的编写逻辑,在各种框架代码中使用也越来越多. 一.注解的应用场景 生成doc文档: 编译器类型格式检查: 运行时处理如注入依赖等 二 ...

  9. Centos7创建CA和申请证书 转自https://www.cnblogs.com/mingzhang/p/8949541.html

    Centos7.3创建CA和申请证书 openssl 的配置文件:/etc/pki/tls/openssl.cnf 重要参数配置路径 dir   = /etc/pki/CA               ...

  10. OpenSSL-Win32,rsa,私钥,公钥,1024,2048

    默认是rsa_private_key1024.pem , PEM格式私钥,C# ,PHP 用. 再生成 pkcs8 格式私钥, JAVA 用. 公钥无格式区分. 1024 的: openssl.exe ...