# Path: segmentation/algorithm/felzenszwalb.py
# def felzenszwalb(image, scale=SCALE, sigma=SIGMA, min_size=MIN_SIZE):
#     """Computes Felsenszwalb's efficient graph based image segmentation.
# 
#     Args:
#         image: The image.
#         scale: Float indicating largeness of clusters (optional).
#         sigma: Width of Gaussian kernel used in preprocessing (optional).
#         min_size: Minimum component size. Enforced using postprocessing
#           (optional).
# 
#     Returns:
#         Integer mask indicating segment labels.
#     """
# 
#     image = tf.cast(image, tf.uint8)
# 
#     def _felzenszwalb(image):
#         segmentation = skimage_felzenszwalb(image, scale, sigma, min_size)
#         return segmentation.astype(np.int32)
# 
#     return tf.py_func(_felzenszwalb, [image], tf.int32, stateful=False,
#                       name='felzenszwalb')


import tensorflow as tf
from .felzenszwalb import felzenszwalb



class FelzenszwalbTest(tf.test.TestCase):

    def test_felzenszwalb(self):
        image = tf.constant([
            [[255, 255, 255], [255, 255, 255], [0, 0, 0], [0, 0, 0]],
            [[255, 255, 255], [255, 255, 255], [0, 0, 0], [0, 0, 0]],
            [[0, 0, 0], [0, 0, 0], [255, 255, 255], [255, 255, 255]],
            [[0, 0, 0], [0, 0, 0], [255, 255, 255], [255, 255, 255]],
        ])

        expected = [
            [0, 0, 0, 0],
            [0, 0, 0, 0],
            [0, 0, 0, 0],
            [0, 0, 0, 0],
        ]

        with self.test_session() as sess:

# Path: segmentation/algorithm/felzenszwalb.py
# def felzenszwalb(image, scale=SCALE, sigma=SIGMA, min_size=MIN_SIZE):
#     """Computes Felsenszwalb's efficient graph based image segmentation.
# 
#     Args:
#         image: The image.
#         scale: Float indicating largeness of clusters (optional).
#         sigma: Width of Gaussian kernel used in preprocessing (optional).
#         min_size: Minimum component size. Enforced using postprocessing
#           (optional).
# 
#     Returns:
#         Integer mask indicating segment labels.
#     """
# 
#     image = tf.cast(image, tf.uint8)
# 
#     def _felzenszwalb(image):
#         segmentation = skimage_felzenszwalb(image, scale, sigma, min_size)
#         return segmentation.astype(np.int32)
# 
#     return tf.py_func(_felzenszwalb, [image], tf.int32, stateful=False,
#                       name='felzenszwalb')


# Path: segmentation/algorithm/felzenszwalb_test.py
import tensorflow as tf
from .felzenszwalb import felzenszwalb




class FelzenszwalbTest(tf.test.TestCase):

    def test_felzenszwalb(self):
        image = tf.constant([
            [[255, 255, 255], [255, 255, 255], [0, 0, 0], [0, 0, 0]],
            [[255, 255, 255], [255, 255, 255], [0, 0, 0], [0, 0, 0]],
            [[0, 0, 0], [0, 0, 0], [255, 255, 255], [255, 255, 255]],
            [[0, 0, 0], [0, 0, 0], [255, 255, 255], [255, 255, 255]],
        ])

        expected = [
            [0, 0, 0, 0],
            [0, 0, 0, 0],
            [0, 0, 0, 0],
            [0, 0, 0, 0],
        ]

        with self.test_session() as sess:

            segmentation = felzenszwalb(image)