Added testcase

This commit is contained in:
Vighnesh Birodkar
2014-06-19 02:50:24 +05:30
parent a6c9a5a2a7
commit abcb9cf2ef
5 changed files with 34 additions and 33 deletions
+24 -5
View File
@@ -1,10 +1,29 @@
import numpy as np
from skimage import graph
def test_threshold_cut():
arr = np.array((100,100,3),dtype='uint8')
arr[:50,:50] = 0
arr[:50,50:] = 1
arr[50:,50:] = 2
arr[50:,50:] = 3
img = np.zeros((100,100,3),dtype='uint8')
img[:50,:50] = 255,255,255
img[:50,50:] = 254,254,254
img[50:,:50] = 2,2,2
img[50:,50:] = 1,1,1
labels = np.zeros((100,100),dtype='uint8')
labels[:50,:50] = 0
labels[:50,50:] = 1
labels[50:,:50] = 2
labels[50:,50:] = 3
#print labels
rag = graph.rag_meancolor(img, labels)
#print "no of edges",rag.number_of_edges()
new_labels = graph.threshold_cut(labels, rag, 10)
assert new_labels.max() == 2
#assert False