2017-04-07 28 views
2

テンソルフローで高周波数を抽出する必要があります。 予想通り、基本的に以下のコードndimage.gaussian_filter(img, sigma) からの機能が動作します:テンソルフローでハイパスフィルタを実装する

import tensorflow as tf 
import cv2 
img = cv2.imread(imgpath, cv2.IMREAD_GRAYSCALE) 
img = cv2.normalize(img.astype('float32'), None, 0.0, 1.0, cv2.NORM_MINMAX) 

# Gaussian Filter 
K = np.array([[0.003765,0.015019,0.023792,0.015019,0.003765], 
[0.015019,0.059912,0.094907,0.059912,0.015019], 
[0.023792,0.094907,0.150342,0.094907,0.023792], 
[0.015019,0.059912,0.094907,0.059912,0.015019], 
[0.003765,0.015019,0.023792,0.015019,0.003765]], dtype='float32') 

# as tensorflow constants with correct shapes 
x = tf.constant(img.reshape(1,img.shape[0],img.shape[1], 1)) 
w = tf.constant(K.reshape(K.shape[0],K.shape[1], 1, 1)) 


with tf.Session() as sess: 
    # get low/high pass ops 
    lowpass = tf.nn.conv2d(x, w, strides=[1, 1, 1, 1], padding='SAME') 
    highpass = x-lowpass 

    # get high pass image 
    l = sess.run(highpass) 
    l = l.reshape(img.shape[0],img.shape[1]) 

    imshow(l) 

私はガウス重みが与えられたシグマとtensorflow以内に形成し得るのか分からないが。

答えて

0

だけuはランダムにランダムシグマ(0、sigma_max)とガウスフィルタを適用することにより、画像をぼかすadd_random_blur(sigma_max = 5.0)を見つけることができ、ここでhttp://tflearn.org/data_augmentation/ augmentation-このtflearnデータを参照します。

関連する問題