Ejemplo n.º 1
0
def gauss_smooth(mask, FILTER_SIZE):
    SIGMA = 0.3 * (
        (FILTER_SIZE - 1) * 0.5 - 1) + 0.8  #0.3*(FILTER_SIZE-1) + 0.8
    smoother = Smoother({'data': mask}, FILTER_SIZE, SIGMA)
    new_mask = smoother.get_output()

    return new_mask
Ejemplo n.º 2
0
    def gauss_smooth(self, mask, FILTER_SIZE):
        '''
        A tensorflow gauss smooth function.
        Args:
            mask: A 'Tensor' that to be smoothed
            FILTER_SIZE: Spatial size of gaussian filter
        Output:
            A gauss smoothed 'Tensor' of same size as 'mask'
        '''
        SIGMA = 0.3 * (
            (FILTER_SIZE - 1) * 0.5 - 1) + 0.8  #0.3*(FILTER_SIZE-1) + 0.8
        smoother = Smoother({'data': mask}, FILTER_SIZE, SIGMA)
        new_mask = smoother.get_output()

        return new_mask
Ejemplo n.º 3
0
Archivo: blur.py Proyecto: zhcv/summary
def smooth():
    input_image = tf.placeholder(tf.float32, shape=[1, None, None, 3])
    smoother = Smoother({'data': input_image}, FILTER_SIZE, SIGMA)
    smoothed_image = smoother.get_output()

    init = tf.global_variables_initializer()
    with tf.Session() as sess:
        sess.run(init)
        image = Image.open(FLAGS.image_path)
        image = np.array(image, dtype=np.float32)
        image = image.reshape((1, image.shape[0], image.shape[1], 1))
        smoothed = sess.run(smoothed_image, 
            feed_dict={image_input: image})
        smoothed = smoothed / np.max(smoothed)

        out_image = np.squeeze(smoothed)
        out_image = Image.fromarray(np.squeeze(np.uint8(out_image * 255)))
Ejemplo n.º 4
0
def smooth():

    Image_Placeholder = tf.placeholder( tf.float32, shape = [1, None, None, 3])
    smoother = Smoother({'data':Image_Placeholder}, FILTER_SIZE, SIGMA)
    smoothed_image = smoother.get_output()

    init = tf.initialize_all_variables()

    with tf.Session() as sess:
        sess.run(init)
        image = Image.open(FLAGS.image_path)
        image = np.array(image, dtype = np.float32)
        image = image.reshape((1, image.shape[0], image.shape[1], 3))
        smoothed = sess.run(smoothed_image,
                             feed_dict = {Image_Placeholder: image})
        smoothed = smoothed / np.max(smoothed)
        out_image = np.squeeze(smoothed)

        out_image = Image.fromarray(np.squeeze(np.uint8(out_image * 255)))
        out_image.show()