CNN处理图片

In [5]:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import tensorflow as tf

import matplotlib.pyplot as plt

import numpy as np




# 平滑均值滤波
#KaTeX parse error: Expected 'EOF', got '_' at position 14: \text {filter_̲{arg}=np.}.full (shape=[3, \text {(shape=[3,} (shape=[3,, 3, 1, 1], fill_value=1 / 9)

# # 高斯平滑滤波
f i l t e r a r g = n p . filter_arg=np. filterarg=np. . a r r a y ( [ [ 1 / 16 , 2 / 16 , .array([[1/16,2/16, .array([[1/16,2/16, / / / / / /,[2/16,4/16,2/16],[1/16,2/16,1/16]]).reshape([3,3,1,1​
pic3=tf. \text {pic3=tf.} pic3=tf..constant(pic2, dt ype=tf \text {ype=tf} ype=tf.float32)

KaTeX parse error: Expected 'EOF', got '_' at position 14: \text {filter_̲{arg}}=\text {t….constant(filter_arg, dtype=tf.float32)

# 卷积
KaTeX parse error: Expected 'EOF', got '_' at position 11: \text {pic_̲{cnn}}=\text {t….nn.conv2d(pic3, fil t e r = f i l t e r a r g , ter=filter_arg, ter=filterarg, strides = = =[1, 1, 1, 1], padding=‘SAME’)



with tf.Session() as sess:
KaTeX parse error: Expected 'EOF', got '_' at position 25: …c4=sess.run(pic_̲{cnn})} print(pic4.shape)
plt.imshow(pic4.transpose([3,1,2,0]).reshape([582,1024,3]).astype(np.uint8)/255)
# 图片灰度化处理
s = − 1 ) s=-1) s=1).astype(np.uin # plt.show()
pic = = = plt.imread(‘./欧式.jpg’)
pic2 = = = pic.reshape([1, 582, 1024, 3]).transpose([3,1,2,0])
# plt.imshow(pic4.transpose( [ 3 , 1 , 2 , 0 ] [3,1,2,0] [3,1,2,0]).reshape((582,1024,3)).mean(axi

(3, 582, 1024, 1)

In [3]:1plt.imshow(pic)

Out[3]: <matplotlib.image.AxesImage at 0x1d088552198>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值