吴裕雄 python深度学习与实践(7)
import cv2
import numpy as np img = np.mat(np.zeros((,)))
cv2.imshow("test",img)
cv2.waitKey()
import cv2
import numpy as np img = np.mat(np.zeros((,),dtype=np.uint8))
cv2.imshow("test",img)
cv2.waitKey()
import cv2
import numpy as np image = np.mat(np.zeros((,)))
imageByteArray = bytearray(image)
print(imageByteArray)
imageBGR = np.array(imageByteArray).reshape(,)
cv2.imshow("cool",imageBGR)
cv2.waitKey()
import os
import cv2
import numpy as np randomByteArray = bytearray(os.urandom())
flatNumpyArray = np.array(randomByteArray).reshape(,)
cv2.imshow("cool",flatNumpyArray)
cv2.waitKey()
import cv2
import numpy as np
img = np.zeros((,))
img[,] =
cv2.imshow("img",img)
cv2.waitKey()
import cv2
import numpy as np img = np.zeros((300,300))
img[:,10] = 255
img[10,:] = 255
cv2.imshow("img",img)
cv2.waitKey(0)
import cv2
import numpy as np from scipy import ndimage kernel33 = np.array([[-1,-1,-1],
[-1,8,-1],
[-1,-1,-1]]) kernel33_D = np.array([[1,1,1],
[1,-8,1],
[1,1,1]]) img = cv2.imread("G:\\MyLearning\\TensorFlow_deep_learn\\data\\lena.jpg",0)
linghtImg = ndimage.convolve(img,kernel33_D)
cv2.imshow("img",linghtImg)
cv2.waitKey()

import numpy as np
import cv2
from scipy import ndimage img = cv2.imread("lena.jpg",0)
blurred = cv2.GaussianBlur(img,(11,11),0)
gaussImg = img - blurred
cv2.imshow("img",gaussImg)
cv2.waitKey()

import numpy as np def convolve(dateMat,kernel):
m,n = dateMat.shape
km,kn = kernel.shape
newMat = np.ones(((m - km + 1),(n - kn + 1)))
tempMat = np.ones(((km),(kn)))
for row in range(m - km + 1):
for col in range(n - kn + 1):
for m_k in range(km):
for n_k in range(kn):
tempMat[m_k,n_k] = dateMat[(row + m_k),(col + n_k)] * kernel[m_k,n_k]
newMat[row,col] = np.sum(tempMat)
return newMat dateMat = np.mat([
[1,2,1,2,0,1,0,1,1],
[0,3,1,1,0,0,1,0,1],
[1,2,1,0,2,1,1,0,0],
[2,2,0,1,1,1,1,1,0],
[3,1,1,0,1,1,0,0,1],
[1,0,1,1,1,0,0,1,1],
[1,1,1,1,0,1,1,1,1],
[1,0,1,1,0,1,0,1,0],
[0,1,1,1,1,2,0,1,0]
]) kernel = np.mat([
[1,0,1],
[0,-4,0],
[1,0,1]
]) newMat = convolve(dateMat,kernel)
print(np.shape(newMat))
print(newMat)

吴裕雄 python深度学习与实践(7)的更多相关文章
- 吴裕雄 python深度学习与实践(18)
# coding: utf-8 import time import numpy as np import tensorflow as tf import _pickle as pickle impo ...
- 吴裕雄 python深度学习与实践(17)
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data import time # 声明输 ...
- 吴裕雄 python深度学习与实践(16)
import struct import numpy as np import matplotlib.pyplot as plt dateMat = np.ones((7,7)) kernel = n ...
- 吴裕雄 python深度学习与实践(15)
import tensorflow as tf import tensorflow.examples.tutorials.mnist.input_data as input_data mnist = ...
- 吴裕雄 python深度学习与实践(14)
import numpy as np import tensorflow as tf import matplotlib.pyplot as plt threshold = 1.0e-2 x1_dat ...
- 吴裕雄 python深度学习与实践(13)
import numpy as np import matplotlib.pyplot as plt x_data = np.random.randn(10) print(x_data) y_data ...
- 吴裕雄 python深度学习与实践(12)
import tensorflow as tf q = tf.FIFOQueue(,"float32") counter = tf.Variable(0.0) add_op = t ...
- 吴裕雄 python深度学习与实践(11)
import numpy as np from matplotlib import pyplot as plt A = np.array([[5],[4]]) C = np.array([[4],[6 ...
- 吴裕雄 python深度学习与实践(10)
import tensorflow as tf input1 = tf.constant(1) print(input1) input2 = tf.Variable(2,tf.int32) print ...
- 吴裕雄 python深度学习与实践(9)
import numpy as np import tensorflow as tf inputX = np.random.rand(100) inputY = np.multiply(3,input ...
随机推荐
- linux (centOS)安装 oracle 11g 以及卸载oracle
目录 首先.1. 一.参数以及环境配置 1.创建用户和组 2.创建数据库软件目录和数据文件存放目录 3.配置oracle用户的环境变量 4.修改linux内核,修改/etc/sysctl.conf文件 ...
- 【转载】 TensorflowOnSpark:1)Standalone集群初体验
原文地址: https://blog.csdn.net/jiangpeng59/article/details/72867368 作者:PJ-Javis 来源:CSDN --------------- ...
- 桥接模式-pattern系列
git链接 桥接模式 桥梁模式的用意是"将抽象化(Abstraction)与实现化(Implementation)脱耦,使得二者可以独立地变化".这句话有三个关键词,也就是抽象化. ...
- spring(三、spring中的eheche缓存、redis使用)
spring(三.spring中的eheche缓存.redis使用) 本文主要介绍为什么要构建ehcache+redis两级缓存?以及在实战中如何实现?思考如何配置缓存策略更合适?这样的方案可能遗留什 ...
- Linux 挂载windows目录
1.默认情况下,Linux服务器会装有samba-client,但是没有装samba-server.但是访问Windows系统共享,安装有samba-client就可以了. [root@test ~] ...
- Cocos2dx利用intersectsRect函数检测碰撞
if (sp1->boundingBox().intersectsRect(sp2->boundingBox())) { pLabel->setString(“碰撞飞机爆炸”); } ...
- LVS DR模式搭建、keepalived+lvs
1.LVS DR模式搭建 条件: 即三台机器,在同一内网. 编辑脚本文件:/usr/local/sbin/lvs_dr.sh #! /bin/bashecho 1 > /proc/sys/net ...
- Linq分组查询统计
这里介绍Linq使用Group By和Count得到每个CategoryID中产品的数量,Linq使用Group By和Count得到每个CategoryID中断货产品的数量等方面. 学经常会遇到Li ...
- goaccess iis w3c 自定义log 格式参考
goaccess 支持强大的自定义log 格式,比如我们需要分析iis w3c 格式日志 参考iis w3c 字段 date time s-ip cs-method cs-uri-stem cs-ur ...
- live555 交叉编译移植到海思开发板
本文章参考了.http://blog.csdn.net/lawishere/article/details/8182952,写了hi3518的配置说明.特此感谢 https://blog.csdn.n ...