In [5]:
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [6]:
import gp


Using gpu device 0: GeForce GTX TITAN (CNMeM is disabled, CuDNN 4007)
/home/d/nolearn/local/lib/python2.7/site-packages/theano/tensor/signal/downsample.py:6: UserWarning: downsample module has been moved to the theano.tensor.signal.pool module.
  "downsample module has been moved to the theano.tensor.signal.pool module.")

In [7]:
input_image, input_prob, input_gold, input_rhoana, dojo_bbox = gp.Legacy.read_dojo_data()

In [8]:
gp.Util.view_labels(input_rhoana[8], [68,70], crop=False)



In [9]:
binary = gp.Util.view_labels(input_rhoana[8], [68,70], crop=False, return_it=True)
splitted = np.array(binary)

In [10]:
binary[binary==1] = 2

In [11]:
imshow(binary)


Out[11]:
<matplotlib.image.AxesImage at 0x7f1449840bd0>

In [12]:
imshow(splitted)


Out[12]:
<matplotlib.image.AxesImage at 0x7f1449779a90>

In [13]:
gp.Util.vi(binary.astype(np.uint64), input_gold[8].astype(np.uint64))


Out[13]:
0.9781710987371827

In [14]:
gp.Util.vi(splitted.astype(np.uint64), input_gold[8].astype(np.uint64))


Out[14]:
1.1039548495432179

In [15]:
imshow(input_gold[8])


Out[15]:
<matplotlib.image.AxesImage at 0x7f144972b050>

In [16]:
gp.Util.view((input_gold[8] + splitted).astype(np.uint64),large=True)



In [17]:
imshow(input_gold[8] + binary)


Out[17]:
<matplotlib.image.AxesImage at 0x7f1449587410>

In [18]:
splitted1 = np.array(splitted)
splitted2 = np.array(splitted)

In [19]:
splitted1[splitted1==1] = 0

In [20]:
imshow(splitted1)


Out[20]:
<matplotlib.image.AxesImage at 0x7f14484ae150>

In [21]:
splitted2[splitted2==2] = 0

In [22]:
imshow(splitted2)


Out[22]:
<matplotlib.image.AxesImage at 0x7f1449757d50>

In [23]:
gp.Util.vi(splitted1.astype(np.uint64), input_gold[8].astype(np.uint64))


Out[23]:
0.47895063243286246

In [24]:
gp.Util.vi(splitted2.astype(np.uint64), input_gold[8].astype(np.uint64))


Out[24]:
0.8530532196776562

In [26]:
plt.subplot(1,3,1)
imshow(input_gold[8])
plt.subplot(1,3,2)
imshow(splitted)
plt.subplot(1,3,3)
imshow(binary)


Out[26]:
<matplotlib.image.AxesImage at 0x7f144832c310>

In [27]:
input_gold.dtype


Out[27]:
dtype('uint32')

In [28]:
splitted.dtype


Out[28]:
dtype('float64')

In [29]:
binary.dtype


Out[29]:
dtype('float64')

In [36]:
gp.Util.vi(splitted.astype(np.uint64).flatten(), input_gold[8].astype(np.uint64).flatten())


Out[36]:
1.1039548495432179

In [33]:
gp.Util.vi(binary.astype(np.uint64).flatten(), input_gold[8].astype(np.uint64).flatten())


Out[33]:
0.9781710987371827

In [46]:
print np.unique(binary)
print np.unique(splitted)
print np.unique(input_gold[8])


[ 0.  2.]
[ 0.  1.  2.]
[ 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
 50 51 52 53 54 55 56]

In [49]:
test = input_gold[8]*(binary>0)
print np.unique(test)


[ 0 41 43 44 45 50 51 52 53 55]

In [59]:
# 43, 52

gt = np.zeros_like(test)
gt[test==43] = 1
gt[test==52] = 2

imshow(gt)


Out[59]:
<matplotlib.image.AxesImage at 0x7f143b5652d0>

In [60]:
gp.Util.vi(binary.astype(np.uint64).flatten(), gt.astype(np.uint64).flatten())


Out[60]:
0.6931450975260867

In [61]:
gp.Util.vi(splitted.astype(np.uint64).flatten(), gt.astype(np.uint64).flatten())


Out[61]:
0.8416733242191282

In [65]:
imshow(binary+gt)


Out[65]:
<matplotlib.image.AxesImage at 0x7f143b295310>

In [64]:
imshow(splitted+gt)


Out[64]:
<matplotlib.image.AxesImage at 0x7f143b361dd0>

In [74]:
test = binary.copy()
test[gt==1] = 5

In [75]:
imshow(test)


Out[75]:
<matplotlib.image.AxesImage at 0x7f143ae9e110>

In [76]:
gp.Util.vi(test.astype(np.uint64).flatten(), gt.astype(np.uint64).flatten())


Out[76]:
0.0

In [78]:
mask = test==5
imshow(mask+binary)


Out[78]:
<matplotlib.image.AxesImage at 0x7f143ad6cd50>

In [79]:
gp.Util.vi((mask+binary).astype(np.uint64).flatten(), gt.astype(np.uint64).flatten())


Out[79]:
0.0

In [80]:
import mahotas

In [114]:
mask = test==5
mask_orig = mask.copy()
values = []

for i in xrange(40):
    mask = mahotas.erode(mask)
    vi = gp.Util.vi((mask+binary).astype(np.uint64).flatten(), gt.astype(np.uint64).flatten())
    #print i, vi
    values.append(vi)
    imshow(mask+binary)
    plt.show()



In [115]:
plt.plot(values)


Out[115]:
[<matplotlib.lines.Line2D at 0x7f14394a8890>]

In [116]:
imshow(gt)


Out[116]:
<matplotlib.image.AxesImage at 0x7f143a62f150>

In [ ]: