# -*- coding: utf-8 -*-
"""
Created on Wed Jun 6 13:38:42 2018
@author: Administrator
"""
import cv2
import numpy as np
import scipy.signal
img = cv2.imread('img_roi_4.bmp', 0)
img_double = np.array(img, dtype = np.float64)
cluster_num = 2
max_iter = 200
label = np.random.randint(1, cluster_num + 1, size = img_double.shape)
#label = 2 * np.ones((70, 70))
iter = 0
f_u = np.array([0,1,0,0,0,0,0,0,0]).reshape(3, 3)
f_d = np.array([0,0,0,0,0,0,0,1,0]).reshape(3, 3)
f_l = np.array([0,0,0,1,0,0,0,0,0]).reshape(3, 3)
f_r = np.array([0,0,0,0,0,1,0,0,0]).reshape(3, 3)
f_ul = np.array([1,0,0,0,0,0,0,0,0]).reshape(3, 3)
f_ur = np.array([0,0,1,0,0,0,0,0,0]).reshape(3, 3)
f_dl