2017-04-07 3 views
2

나는 tensorflow에서 고주파수 이미지를 추출해야합니다. 는 기본적으로 ndimage.gaussian_filter(img, sigma) 의 기능 다음 코드는 예상대로 작동합니다 tensorflow에서 고역 통과 필터 구현

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

단지 본 tflearn 데이터 여기서 u는 add_random_blur 찾을 수 http://tflearn.org/data_augmentation/을 augmentation- 참조 임의로 랜덤 시그마 (0, sigma_max) 가우시안 필터를 적용한 화상 흐림 (sigma_max = 5.0).

관련 문제