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. Ubuntu16.04上添加用户以及修改用户所属的组

    我的问题是这样的,我的本地的电脑上有一个用户以及一个用户组,我还想添加其他的用户,并且这个用户属于这个已有的用户组 <鸟哥的linux私房菜>针对的是centos系统,还是有一些不一样 实 ...

  2. 【转】使用Mybatis时遇到的延迟加载造成返回异常的问题——HttpMessageConversionException: Type definition error

    在使用Mybatis的过程中,使用了resultMap延迟加载. 延迟加载:association联表查询的过程中,查询另外两个表的对象.而延迟加载是指只有在使用这两个对象的时候才会进行查询. 问题的 ...

  3. javascript 运算符优先级

    JavaScript 运算符优先级(从高到低) https://github.com/xhlwill/blog/issues/16 今天把js函数转换为python 函数时,发现在js运算符优先级这边 ...

  4. ccf-棋局评估-20190304

    三更:  更短的代码,更短的时间,加油! 也祝你好运哦!!!! 核心: dfs(player)  player下完之后最大得分 优点: 我位运算掌握的还不错嘛 2和1如何转换  2^3=1; 1^3= ...

  5. c++ 快速读入输出

    1. 读入优化 C++中有一个函数:getchar() ,用于读入字符,那么这跟读入整数有什么关系呢? 其实,经过类似高精度的处理,就可以实现类型转换啦! 下面是正负数读入优化模板: #include ...

  6. linux子系统搭建python3

    我之前win10系统有py3,所以就没有下载,直接输入python ,就会进入python环境,但是,什么包都没有 安装pip $ wget https://bootstrap.pypa.io/get ...

  7. ROS下利用realsense采集RGBD图像合成点云

    摘要:在ROS kinetic下,利用realsense D435深度相机采集校准的RGBD图片,合成点云,在rviz中查看点云,最后保存成pcd文件. 一. 各种bug 代码编译成功后,打开rviz ...

  8. js鼠标拖动(转载)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  9. Hadoop 权限管理

    Hadoop的权限管理同Linux的很像,有用户,用户组之分,同时Hadoop提供了权限管理命令,主要包括: chmod [-R] mode file … 只有文件的所有者或者超级用户才有权限改变文件 ...

  10. Scrapy学习篇(十三)之scrapy+selenum获取网站cookie并保存带本地

    参考:https://www.cnblogs.com/small-bud/p/9064674.html 和selenium登录51job的例子