吴裕雄 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 ...
随机推荐
- ubuntu16.04+caffe+GPU+cuda+cudnn安装教程
步骤简述: 1.安装GPU驱动(系统适配,不采取手动安装的方式) 2.安装依赖(cuda依赖库,caffe依赖) 3.安装cuda 4.安装cudnn(只是复制文件加链接,不需要编译安装的过程) 5. ...
- Spring mvc 加载HTML静态页面
看到网上大部分举例Spring MVC加载静态页面HTML方式都还要通过controller, 根据js和css文件的加载模式,html也同样可以直接加载 在spring的配置文件中例如 *-serv ...
- Beanshell断言
Beanshell断言示例一:通过从数据库查询结果集,和从接口返回中解析json格式的返回内容,比较两者来验证sample请求是否成功 1>先通过JDBC PreProcessor把测试计划中所 ...
- Ubuntu16.04的sublime text3 的安装教程
1. sublime text3的官网位置 https://www.sublimetext.com/3 2.apt安装方式 1. 安装 GPG -key: wget -qO - https://do ...
- LiquiBase 学习
preconditions mysql database is installed maven has been setted up properly add depedenceies apply p ...
- C#高低位分解转换备忘
private void Form1_Load(object sender, EventArgs e) { , , , , , ); var arr = long2LowHight(time.ToFi ...
- jar包不能乱放【浪费了下午很多时间】
不能放在类路径下(也即是src文件夹下),然后再buildpath 必须放在web-inf文件夹下 这样才能tomcat找打jar文件
- java-启动和关闭.exe程序
链接: https://www.cnblogs.com/pengpengzhang/p/8675740.html https://blog.csdn.net/ZHANGHUI3239619/artic ...
- Bootstrap格式转换代码
网址:http://www.w3cschool.cc/bootstrap/bootstrap-responsive-utilities.html <div class="contain ...
- django路由系统URLS
usrls: from django.contrib import admin from django.urls import path from cmbd import views from dja ...